Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: appengine/third_party_local/depot_tools/git_number.py

Issue 1052993003: Roll multiple files from depot_tools into luci. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/third_party_local/depot_tools/git_number.py
diff --git a/appengine/third_party_local/depot_tools/git_number.py b/appengine/third_party_local/depot_tools/git_number.py
index 04f676c655d8db6c75c36a6205e1ef152365e8e3..1867b97d7ca58b68856fa495cd303ca6907bbe10 100755
--- a/appengine/third_party_local/depot_tools/git_number.py
+++ b/appengine/third_party_local/depot_tools/git_number.py
@@ -37,6 +37,8 @@ CHUNK_FMT = '!20sL'
CHUNK_SIZE = struct.calcsize(CHUNK_FMT)
DIRTY_TREES = collections.defaultdict(int)
REF = 'refs/number/commits'
+AUTHOR_NAME = 'git-number'
+AUTHOR_EMAIL = 'chrome-infrastructure-team@google.com'
# Number of bytes to use for the prefix on our internal number structure.
# 0 is slow to deserialize. 2 creates way too much bookeeping overhead (would
@@ -153,7 +155,14 @@ def finalize(targets):
assert updater.returncode == 0
tree_id = git.run('write-tree', env=env)
- commit_cmd = ['commit-tree', '-m', msg, '-p'] + git.hashes(REF)
+ commit_cmd = [
+ # Git user.name and/or user.email may not be configured, so specifying
+ # them explicitly. They are not used, but requried by Git.
+ '-c', 'user.name=%s' % AUTHOR_NAME,
+ '-c', 'user.email=%s' % AUTHOR_EMAIL,
+ 'commit-tree',
+ '-m', msg,
+ '-p'] + git.hash_multi(REF)
for t in targets:
commit_cmd.extend(['-p', binascii.hexlify(t)])
commit_cmd.append(tree_id)
@@ -243,25 +252,33 @@ def main(): # pragma: no cover
levels = [logging.ERROR, logging.INFO, logging.DEBUG]
logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])
- try:
- if opts.reset:
- clear_caches(on_disk=True)
- return
+ # 'git number' should only be used on bots.
+ if os.getenv('CHROME_HEADLESS') != '1':
+ logging.error("'git-number' is an infrastructure tool that is only "
+ "intended to be used internally by bots. Developers should "
+ "use the 'Cr-Commit-Position' value in the commit's message.")
+ return 1
- try:
- targets = git.parse_commitrefs(*(args or ['HEAD']))
- except git.BadCommitRefException as e:
- parser.error(e)
+ if opts.reset:
+ clear_caches(on_disk=True)
+ return
- load_generation_numbers(targets)
- if not opts.no_cache:
- finalize(targets)
+ try:
+ targets = git.parse_commitrefs(*(args or ['HEAD']))
+ except git.BadCommitRefException as e:
+ parser.error(e)
- print '\n'.join(map(str, map(get_num, targets)))
- return 0
- except KeyboardInterrupt:
- return 1
+ load_generation_numbers(targets)
+ if not opts.no_cache:
+ finalize(targets)
+
+ print '\n'.join(map(str, map(get_num, targets)))
+ return 0
if __name__ == '__main__': # pragma: no cover
- sys.exit(main())
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ sys.stderr.write('interrupted\n')
+ sys.exit(1)
« no previous file with comments | « appengine/third_party_local/depot_tools/git_common.py ('k') | appengine/third_party_local/depot_tools/subcommand.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698