diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-15 20:49:18 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-01-02 21:31:20 +0100 |
commit | 65d0867a25e32915e73cadf4bdc90c58ed11bfc1 (patch) | |
tree | 6a8a52b06e04acb71f38a6d8196e6b0ac2581d14 | |
parent | eaf86a22d33c1f82f2989908b9a9a3ca775448d5 (diff) | |
download | rockbox-65d0867a25e32915e73cadf4bdc90c58ed11bfc1.tar.gz rockbox-65d0867a25e32915e73cadf4bdc90c58ed11bfc1.tar.bz2 rockbox-65d0867a25e32915e73cadf4bdc90c58ed11bfc1.zip |
rbutil: Add option to langstat to pass git hash.
Don't always operate on the remote head, instead default to the local
HEAD, and allow passing a hash to use for calculating statistics.
Change-Id: I420308e66769689c1dfac56e19058b097a0533a2
-rwxr-xr-x | rbutil/rbutilqt/langstats.py | 11 | ||||
-rwxr-xr-x | utils/common/gitscraper.py | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/rbutil/rbutilqt/langstats.py b/rbutil/rbutilqt/langstats.py index 7a1fc4f703..cbf49dce08 100755 --- a/rbutil/rbutilqt/langstats.py +++ b/rbutil/rbutilqt/langstats.py @@ -65,18 +65,20 @@ def main(): description='Print translation statistics for pasting in the wiki.') parser.add_argument('-p', '--pretty', action='store_true', help='Display pretty output instead of wiki-style') + parser.add_argument('-c', '--commit', nargs='?', help='Git commit hash') args = parser.parse_args() - langstat(args.pretty) + langstat(args.pretty, args.commit) -def langstat(pretty=True): +def langstat(pretty=True, tree=None): '''Get translation stats and print to stdout.''' # get gitpaths to temporary folder workfolder = tempfile.mkdtemp() + "/" repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) - tree = gitscraper.get_refs(repo)['refs/remotes/origin/master'] + if tree is None: + tree = gitscraper.get_refs(repo)['HEAD'] filesprops = gitscraper.scrape_files( repo, tree, GITPATHS, dest=workfolder, timestamp_files=["rbutil/rbutilqt/lang"]) @@ -130,8 +132,7 @@ def langstat(pretty=True): "| *Done* |") # scan output - for i in range(len(lines)): - line = lines[i] + for i, line in enumerate(lines): if re_updating.search(line): lang = re_qmlang.findall(line) tsfile = "rbutil/rbutilqt/lang/%s.ts" % re_qmbase.findall(line)[0] diff --git a/utils/common/gitscraper.py b/utils/common/gitscraper.py index c7a2c3a563..5b3b316115 100755 --- a/utils/common/gitscraper.py +++ b/utils/common/gitscraper.py @@ -43,7 +43,7 @@ def get_refs(repo): ''' print("Getting list of refs") output = subprocess.Popen( - ["git", "show-ref", "--abbrev"], + ["git", "show-ref", "--abbrev", "--head"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) cmdout = output.communicate() refs = dict() |