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()