From 95611aaf1d43c230130b5404f63fc80ed14bddd5 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Fri, 5 Feb 2010 20:14:54 -0800 Subject: Add a function to find the latest remote commit This is hardcoded to origin/master right now as chain-build is the only real consumer of this and chain-build only works on rawhide. Eventually this could probably take a branch name to get a commit for, or return all the heads or something. --- src/pyfedpkg/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index b822388..fbecb8e 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -187,6 +187,24 @@ def clone_with_dirs(module, user): (module, user)) return +def get_latest_commit(module): + """Discover the latest commit has for a given module and return it""" + + # This is stupid that I have to use subprocess :/ + url = ANONGITURL % {'module': module} + cmd = ['git', 'ls-remote', url, 'master'] + try : + proc = subprocess.Popen(cmd, stderr=subprocess.PIPE, + stdout=subprocess.PIPE) + output, error = proc.communicate() + except OSError, e: + raise FedpkgError(e) + if error: + raise FedpkgError('Got an error finding head for %s: %s' % + (module, error)) + # Return the hash sum + return output.split()[0] + def new(path=os.getcwd()): """Return changes in a repo since the last tag""" -- cgit