summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-10-17 20:56:15 +0100
committerLars Wirzenius <liw@liw.fi>2011-10-17 20:56:15 +0100
commita7d16bcc787fbce9e6ef431dead91a54bf8a50ca (patch)
tree998d0bf3053879973e936f63866f6757a2f70d91 /morphlib/git.py
parent98507401bd5e3d52b448c7890f952f1a5ff01567 (diff)
downloadmorph-a7d16bcc787fbce9e6ef431dead91a54bf8a50ca.tar.gz
Move get_git_commit_id into morphlib.git and rename.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 47eb7ffe..f3403e2b 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -16,6 +16,7 @@
import gzip
import logging
+import urlparse
import morphlib
@@ -28,3 +29,14 @@ def export_sources(repo, ref, tar_filename):
f.write(tar)
f.close()
+
+def get_commit_id(repo, ref):
+ '''Return the full SHA-1 commit id for a repo+ref.'''
+ # FIXME: This assume repo is a file:/// URL.
+
+ scheme, netlock, path, params, query, frag = urlparse.urlparse(repo)
+ assert scheme == 'file'
+ ex = morphlib.execute.Execute(path, msg=logging.debug)
+ out = ex.runv(['git', 'rev-list', '-n1', ref])
+ return out.strip()
+