Skip to content

Instantly share code, notes, and snippets.

@ntkathole
Created June 26, 2019 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntkathole/cb8d091a04e35ecd4922356d6e25b800 to your computer and use it in GitHub Desktop.
Save ntkathole/cb8d091a04e35ecd4922356d6e25b800 to your computer and use it in GitHub Desktop.
"Modified from project : https://pypi.org/project/PyHatch/"
import requests
import os
import datetime
import getpass
GITHUB_USER = 'ntkathole'
here = os.path.abspath(os.path.dirname(__file__))
print( '='*55 )
print( ' Building HISTORY.rst file' )
print( ' at: ' + here )
print( ' Need GitHub user password for ' + GITHUB_USER)
print( '='*55 )
PASSWORD = getpass.getpass(prompt='Enter Password: ')
github_url = "https://api.github.com/repos/SatelliteQE/robottelo/commits"
headers = {'content-type': 'application/json'}
t = requests.get(github_url, auth=(GITHUB_USER,PASSWORD))
fOut = open(os.path.join(here, 'HISTORY.rst'), 'w')
fOut.write("""
History
=======
GitHub Log
----------
""")
print( 'len(t.json()) =' + '%s'%len(t.json()) )
last_date_str = ''
last_author_str = ''
for D in t.json():
date_str = D['commit']['author']['date'][:10]
author_str = D['commit']['author']['name']
if date_str != last_date_str:
com_date = datetime.datetime.strptime(date_str, '%Y-%m-%d').date()
fOut.write( '* ' + com_date.strftime('%b %d, %Y') + '\n' )
if (date_str != last_date_str) or (author_str != last_author_str):
fOut.write( ' ' +'- (by: %s) '%author_str + '\n' )
msgL = D['commit']['message'].split('\n')
pad = ' - '
for msg in msgL:
if msg:
fOut.write(pad + '%s'%msg + '\n' )
else:
pad = ' '
print( D['commit']['author']['date'][:10] + ' ' + D['commit']['message'] )
last_date_str = date_str
last_author_str = author_str
fOut.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment