| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2015 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 """Outputs the timestamp of the last commit in a Git repository.""" | |
| 8 | |
| 9 import argparse | |
| 10 import subprocess | |
| 11 import sys | |
| 12 | |
| 13 def get_timestamp(directory): | |
| 14 return subprocess.check_output(["git", "log", "-1", "--pretty=format:%ct"], | |
| 15 cwd=directory) | |
| 16 | |
| 17 def main(): | |
| 18 parser = argparse.ArgumentParser(description="Prints the timestamp of the " | |
| 19 "last commit in a git repository") | |
| 20 parser.add_argument("--directory", nargs='?', | |
| 21 help="Directory of the git repository", default=".") | |
| 22 parser.add_argument("--output", nargs='?', | |
| 23 help="Output file, or stdout if omitted") | |
| 24 args = parser.parse_args() | |
| 25 | |
| 26 output_file = sys.stdout | |
| 27 if args.output: | |
| 28 output_file = open(args.output, 'w') | |
| 29 | |
| 30 with output_file: | |
| 31 # Print without newline so GN can read it. | |
| 32 output_file.write(get_timestamp(args.directory)) | |
| 33 | |
| 34 if __name__ == '__main__': | |
| 35 sys.exit(main()) | |
| 36 | |
| OLD | NEW |