Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 ''' | |
| 8 Usage: python commit_hash.py SKIA_DIR OUTPUT_FILE | |
| 9 ''' | |
| 10 | |
| 11 import os | |
| 12 import subprocess | |
| 13 import sys | |
| 14 | |
| 15 assert len(sys.argv) == 3 | |
| 16 | |
| 17 template = '''#include "skia/ext/skia_commit_hash.h" | |
| 18 const char* skia::CommitHash() { return "%s"; } | |
| 19 ''' | |
| 20 | |
| 21 try: | |
| 22 commit = subprocess.check_output( | |
| 23 ['git', 'rev-parse', '--short=12', 'HEAD'], | |
| 24 cwd=sys.argv[1]).strip() | |
| 25 except (subprocess.CalledProcessError, OSError), e: | |
| 26 commit = 'UNKNOWN' | |
|
mtklein
2016/07/26 16:11:48
Is failure expected to happen somewhere? Wouldn't
| |
| 27 | |
| 28 with open(sys.argv[2], 'w') as o: | |
| 29 o.write(template % commit) | |
| OLD | NEW |