diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-06-24 22:37:55 -0700 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-06-24 22:37:55 -0700 |
commit | 2da8c0160ca2078c1091a385cc0254e383505c88 (patch) | |
tree | fbcd87c1d4e969f1403745a18ff50068735783c8 /src | |
parent | 7e4fa285cec9d3558c72edfb07cc3df0343db9d1 (diff) | |
download | fedora-packager-2da8c0160ca2078c1091a385cc0254e383505c88.tar.gz fedora-packager-2da8c0160ca2078c1091a385cc0254e383505c88.tar.xz fedora-packager-2da8c0160ca2078c1091a385cc0254e383505c88.zip |
Add a commit function
This should work well whether you're on a real tty or not, but I didn't
test it for the "not a tty" aspect.
Diffstat (limited to 'src')
-rw-r--r-- | src/pyfedpkg/__init__.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index e0c27c1..cc977fe 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -587,6 +587,41 @@ class PackageModule: clogfile.writelines(cloglines) return + def commit(self, message=None, file=None, files=[]): + """Commit changes to a module. + + Can take a message to use as the commit message + + a file to find the commit message within + + and a list of files to commit. + + Requires the caller be a real tty or a message passed. + + Logs the output and returns nothing. + + """ + + # First lets see if we got a message or we're on a real tty: + if not sys.stdin.isatty(): + if not message or not file: + raise FedpkgError('Must have a commit message or be on a real tty.') + + # construct the git command + # We do this via subprocess because the git module is terrible. + cmd = ['git', 'commit'] + if message: + cmd.extend(['-m', message]) + elif file: + cmd.extend(['-F', os.path.abspath(file)]) + if not files: + cmd.append('-a') + else: + cmd.extend(files) + # make it so + _run_command(cmd) + return + def compile(self, arch=None, short=False): """Run rpm -bc on a module |