Created
June 18, 2022 17:54
-
-
Save Dyrcona/61c9f400512436a5639161c33004ac59 to your computer and use it in GitHub Desktop.
Revisions
-
Dyrcona created this gist
Jun 18, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #!/usr/bin/env python3 # -*- Mode: python; coding: utf-8 -*- # --------------------------------------------------------------- # Copyright © 2015, 2022 Jason J.A. Stephenson <jason@sigio.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # --------------------------------------------------------------- import subprocess, sys def gather_args(): args = { "upstream": None, "head": None, "limit": None } if len(sys.argv) > 1: args["upstream"] = sys.argv[1] if len(sys.argv) > 2: args["head"] = sys.argv[2] if len(sys.argv) > 3: args["limit"] = sys.argv[3] return args def gather_commits(upstream=None, head=None, limit=None): args = ["git", "cherry"] if upstream: args.append(upstream) if head: args.append(head) if limit: args.append(limit) with subprocess.Popen(args, stdout=subprocess.PIPE) as git: commits = git.stdout.read().decode('utf8').splitlines() return commits def get_log(commit): with subprocess.Popen(["git", "log", "-n 1", "--pretty=fuller", commit], stdout=subprocess.PIPE) as git: log = git.stdout.read().decode('utf8') return log def main(): cherryArgs = gather_args() for cherry in gather_commits(**cherryArgs): if cherry.startswith('+ '): print(get_log(cherry[2:42])) if __name__ == "__main__": main()