Chromium Code Reviews| Index: skia/commit_hash.py |
| diff --git a/skia/commit_hash.py b/skia/commit_hash.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..03866b6dbfd6bd99123c2fbac7464eae788c571b |
| --- /dev/null |
| +++ b/skia/commit_hash.py |
| @@ -0,0 +1,29 @@ |
| +#!/usr/bin/python |
| + |
| +# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +''' |
| +Usage: python commit_hash.py SKIA_DIR OUTPUT_FILE |
| +''' |
| + |
| +import os |
| +import subprocess |
| +import sys |
| + |
| +assert len(sys.argv) == 3 |
| + |
| +template = '''#include "skia/ext/skia_commit_hash.h" |
| +const char* skia::CommitHash() { return "%s"; } |
| +''' |
| + |
| +try: |
| + commit = subprocess.check_output( |
| + ['git', 'rev-parse', '--short=12', 'HEAD'], |
| + cwd=sys.argv[1]).strip() |
| +except (subprocess.CalledProcessError, OSError), e: |
| + commit = 'UNKNOWN' |
|
mtklein
2016/07/26 16:11:48
Is failure expected to happen somewhere? Wouldn't
|
| + |
| +with open(sys.argv[2], 'w') as o: |
| + o.write(template % commit) |