-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Changelog script to include changes in lib dependencies. #420
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,14 @@ def getTags(): | |
tags = filter(lambda x: "-" not in x, tags) | ||
return natsorted(tags,reverse=True) | ||
|
||
def getCommitsBetween( tagA, tagB = "HEAD" ): | ||
commits = os.popen(f"git -P shortlog {tagA}..{tagB}").read().strip().splitlines() | ||
return "\n".join(map( lambda x: x.replace(" ", " - "), commits )) | ||
def getCommitsBetween( tagA, tagB = "HEAD", dir=None): | ||
if dir: | ||
original_dir = os.getcwd() | ||
os.chdir(dir) | ||
commits = os.popen(f'git log --format="%s (by %an)" --no-merges --reverse {tagA}..{tagB}').read().strip().splitlines() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was no way to change The format includes the git author name at the end of the commit title, in case we wanted to still provide attribution. |
||
if dir: | ||
os.chdir(original_dir) | ||
return "\n - ".join([""] + commits) | ||
|
||
def getRepoURL(): | ||
origin = os.popen("git remote get-url origin").read().strip().split( "github.com/", maxsplit=1 ) | ||
|
@@ -62,6 +67,22 @@ def printLibraryLinks(): | |
for lib in config['libraries']: | ||
output( F" - {lib['name']} = {lib['url']}/tree/{lib['branch']}" ) | ||
|
||
def getOldAndNewLibCommits(old_commit, new_commit): | ||
old_target_locked = json.loads(os.popen(f"git show {old_commit}:target-locked.json").read()) | ||
new_target_locked = json.loads(os.popen(f"git show {new_commit}:target-locked.json").read()) | ||
lib_versions = {} | ||
# We only have a handful of libraries in the list, okay to be inefficient | ||
for old_lib in old_target_locked["libraries"]: | ||
for new_lib in new_target_locked["libraries"]: | ||
if old_lib["name"] == new_lib["name"]: | ||
lib_versions[old_lib["name"]] = { | ||
"old": old_lib["branch"], | ||
"new": new_lib["branch"], | ||
"url": old_lib["url"] | ||
} | ||
return lib_versions | ||
|
||
|
||
tags = getTags() | ||
|
||
defaultTag = "v0.0.1" | ||
|
@@ -109,12 +130,23 @@ def printLibraryLinks(): | |
print( "Nothing to do, Stop." ) | ||
exit( 0 ) | ||
|
||
# Target commits | ||
logURL = f"{url}compare/{lastTag}...{options.tag}" | ||
|
||
output( f"## [{options.tag}]({logURL})", forcePrint=True ) | ||
output( '', forcePrint=True ) | ||
output( getCommitsBetween( lastTag, options.tag ), forcePrint=True ) | ||
|
||
# Library commits | ||
libInfo = getOldAndNewLibCommits( lastTag, options.tag ) | ||
for libName, lib in libInfo.items(): | ||
libCommits = getCommitsBetween(lib['old'], lib['new'], dir=f"../{libName}") | ||
if libCommits: | ||
diffUrl = f"{lib['url']}/compare/{lib['old']}...{lib['new']}" | ||
diffUrlMarkdown = f"[{lib['old'][:7]}...{lib['new'][:7]}]({diffUrl})" | ||
output(f"\n### {libName} ({diffUrlMarkdown})", forcePrint=True) | ||
output(libCommits, forcePrint=True) | ||
|
||
output( '', forcePrint=True ) | ||
|
||
output( line ) | ||
else: | ||
output( line ) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be able to easily run this function in other directories I've added the
dir
parameter to temporarily change the current working directory.