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 /rbutil/rbutilqt | |
parent | eaf86a22d33c1f82f2989908b9a9a3ca775448d5 (diff) | |
download | rockbox-65d0867a25e32915e73cadf4bdc90c58ed11bfc1.tar.gz 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
Diffstat (limited to 'rbutil/rbutilqt')
-rwxr-xr-x | rbutil/rbutilqt/langstats.py | 11 |
1 files changed, 6 insertions, 5 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] |