summaryrefslogtreecommitdiffstats
path: root/src/pyfedpkg/__init__.py
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-07-01 16:34:36 -0700
committerJesse Keating <jkeating@redhat.com>2010-07-01 16:34:36 -0700
commit3e26ff00c6af7d598219a3fc806398424e3a973d (patch)
tree05e5a560028a7a15dd7ef23a2dcf30d12632d641 /src/pyfedpkg/__init__.py
parent498bec7e1dfa119c04136c34dadc52a8c9b53f2f (diff)
downloadfedora-packager-3e26ff00c6af7d598219a3fc806398424e3a973d.tar.gz
fedora-packager-3e26ff00c6af7d598219a3fc806398424e3a973d.tar.xz
fedora-packager-3e26ff00c6af7d598219a3fc806398424e3a973d.zip
Create a (simple) diff command
Diffstat (limited to 'src/pyfedpkg/__init__.py')
-rw-r--r--src/pyfedpkg/__init__.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 784d263..d3e9d62 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -693,6 +693,35 @@ class PackageModule:
_run_command(cmd, shell=True)
return
+ def diff(self, cached=False, files=[]):
+ """Excute a git diff
+
+ optionally diff the cached or staged changes
+
+ Takes an optional list of files to diff reletive to the module base
+ directory
+
+ Logs the output and returns nothing
+
+ """
+
+ # Things work better if we're in our module directory
+ oldpath = os.getcwd()
+ os.chdir(self.path)
+
+ # build up the command
+ cmd = ['git', 'diff']
+ if cached:
+ cmd.append('--cached')
+ if files:
+ cmd.extend(files)
+
+ # Run it!
+ _run_command(cmd)
+ # popd
+ os.chdir(oldpath)
+ return
+
def getver(self):
"""Return the version-release of a package module."""