diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-02-05 20:14:54 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-02-05 20:14:54 -0800 |
commit | 95611aaf1d43c230130b5404f63fc80ed14bddd5 (patch) | |
tree | 6292b6fe5d11ec664199f94471f3bf8296344b7c /src/pyfedpkg | |
parent | 1b5227990712ddbb9a2e4a435b06a913a8df73c6 (diff) | |
download | fedora-packager-95611aaf1d43c230130b5404f63fc80ed14bddd5.tar.gz fedora-packager-95611aaf1d43c230130b5404f63fc80ed14bddd5.tar.xz fedora-packager-95611aaf1d43c230130b5404f63fc80ed14bddd5.zip |
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.
Diffstat (limited to 'src/pyfedpkg')
-rw-r--r-- | src/pyfedpkg/__init__.py | 18 |
1 files changed, 18 insertions, 0 deletions
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""" |