get_non_upstreamed_commits: Make limit argument optional Using the entire history is sensible when the limit is omitted, so we use that as the default. BUG=None TEST=`python3 ~/cos/src/scripts/cos/get_non_upstreamed_commits.py --head HEAD --upstrem cos/upstream/main` and `python3 ~/cos/src/scripts/cos/get_non_upstreamed_commits.py --head HEAD --upstream cos/upstream/main --limit=HEAD~3` Change-Id: Ie5367baf5d88ccc030ab7e65d3e63f9bce770143 Reviewed-on: https://cos-review.googlesource.com/c/cos/scripts/+/237407 Reviewed-by: Derek Taylor <ddtaylor@google.com> Tested-by: Kevin Berry <kpberry@google.com>
diff --git a/get_non_upstreamed_commits.py b/get_non_upstreamed_commits.py index d26327c..1c62f6d 100755 --- a/get_non_upstreamed_commits.py +++ b/get_non_upstreamed_commits.py
@@ -9,7 +9,8 @@ # upstream. # # Like `git cherry`, this script takes arguments for an upstream, a head, and -# a limit. If the head argument is omitted, HEAD is used. +# a limit. If the head argument is omitted, HEAD is used. If the limit is +# omitted, then the entire history leading up to the head will be used. # # The script will do the following: # 1. Get all of the commits which are present between limit and head. @@ -109,9 +110,11 @@ """ commits = [] - with Popen( - ['git', 'cherry', '-v', upstream, head, limit], stdout=PIPE - ) as commit_lines: + cherry_cmd = ['git', 'cherry', '-v', upstream, head] + if limit: + cherry_cmd.append(limit) + + with Popen(cherry_cmd, stdout=PIPE) as commit_lines: for line in commit_lines.stdout: try: line = line.decode('utf-8').strip() @@ -187,7 +190,7 @@ ) parser.add_argument('-u', '--upstream', type=str, required=True) parser.add_argument('--head', type=str, default='HEAD', required=False) - parser.add_argument('-l', '--limit', type=str, required=True) + parser.add_argument('-l', '--limit', default='', type=str, required=False) parser.add_argument( '-s', '--subject-map-revision-range', type=str, required=False )