summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-08-20 14:33:52 -0700
committerJesse Keating <jkeating@redhat.com>2010-08-20 14:33:52 -0700
commit8b5a955077bb7fb652fb2e6082c45b845ba58541 (patch)
tree96c01385809a3f23f8d9c09cb211c9a56998e480 /src
parentb7298298036905bd1360193c2e90ace04e29ec44 (diff)
downloadfedora-packager-8b5a955077bb7fb652fb2e6082c45b845ba58541.zip
fedora-packager-8b5a955077bb7fb652fb2e6082c45b845ba58541.tar.gz
fedora-packager-8b5a955077bb7fb652fb2e6082c45b845ba58541.tar.xz
Move commit out of the PackageModule object.
Outside of clog, there is no reason why commit should need data from the spec file. This fixes a bug when marking a package as dead so that one can commit again. Ticket #54
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fedpkg.py3
-rw-r--r--src/pyfedpkg/__init__.py76
2 files changed, 42 insertions, 37 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index 0a60b64..187f517 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -431,8 +431,7 @@ def clone(args):
def commit(args):
try:
- mymodule = pyfedpkg.PackageModule(args.path)
- mymodule.commit(args.message, args.file, args.files)
+ pyfedpkg.commit(args.path, args.message, args.file, args.files)
except pyfedpkg.FedpkgError, e:
log.error('Could not commit: %s' % e)
sys.exit(1)
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index ae3db2c..a9fcc0d 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -423,6 +423,47 @@ def clone_with_dirs(module, user, path=None):
# successful.
return 0
+def commit(path=None, message=None, file=None, files=[]):
+ """Commit changes to a module (optionally found at path)
+
+ 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.')
+
+ # Deal with path
+ curdir = os.getcwd()
+ if path:
+ os.chdir(path)
+
+ # 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)
+ os.chdir(curdir)
+ return
+
def get_latest_commit(module):
"""Discover the latest commit has for a given module and return it"""
@@ -1041,41 +1082,6 @@ 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