[PATCH] D56422: gn build: Use "git rev-parse --git-dir" to discover the path to the .git directory.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 10 14:00:59 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350897: gn build: Use "git rev-parse --git-dir" to discover the path to the .git… (authored by pcc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D56422?vs=180595&id=181149#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56422/new/
https://reviews.llvm.org/D56422
Files:
llvm/trunk/utils/gn/build/write_vcsrevision.py
Index: llvm/trunk/utils/gn/build/write_vcsrevision.py
===================================================================
--- llvm/trunk/utils/gn/build/write_vcsrevision.py
+++ llvm/trunk/utils/gn/build/write_vcsrevision.py
@@ -12,7 +12,6 @@
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
LLVM_DIR = os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR)))
-MONO_DIR = os.path.dirname(LLVM_DIR)
def which(program):
@@ -36,21 +35,23 @@
if os.path.isdir(os.path.join(LLVM_DIR, '.svn')):
print('SVN support not implemented', file=sys.stderr)
return 1
- if os.path.isdir(os.path.join(LLVM_DIR, '.git')):
+ if os.path.exists(os.path.join(LLVM_DIR, '.git')):
print('non-mono-repo git support not implemented', file=sys.stderr)
return 1
- git_dir = os.path.join(MONO_DIR, '.git')
- if not os.path.isdir(git_dir):
- print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
- return 1
-
git, use_shell = which('git'), False
if not git:
git = which('git.exe')
if not git:
git = which('git.bat')
use_shell = True
+
+ git_dir = subprocess.check_output([git, 'rev-parse', '--git-dir'],
+ cwd=LLVM_DIR, shell=use_shell).strip()
+ if not os.path.isdir(git_dir):
+ print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
+ return 1
+
rev = subprocess.check_output([git, 'rev-parse', '--short', 'HEAD'],
cwd=git_dir, shell=use_shell).decode().strip()
# FIXME: add pizzas such as the svn revision read off a git note?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56422.181149.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190110/47d67f09/attachment.bin>
More information about the llvm-commits
mailing list