From dd57b28231771b06b91af41a4cadfd0d133861ca Mon Sep 17 00:00:00 2001 From: Jochen Schmitt Date: Thu, 16 Sep 2010 20:05:53 +0200 Subject: Move diff function out of the PackageModule class hello Jesse, because you have wrote, that you want a minimum set of functions in the PackageModule clase, I have move the diff function out of their. Best Regards: Jochen Schmitt --- src/fedpkg.py | 3 +-- src/pyfedpkg/__init__.py | 57 ++++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/fedpkg.py b/src/fedpkg.py index 8f90364..70ce711 100755 --- a/src/fedpkg.py +++ b/src/fedpkg.py @@ -485,8 +485,7 @@ def compile(args): def diff(args): try: - mymodule = pyfedpkg.PackageModule(args.path) - return mymodule.diff(args.cached, args.files) + return mymodule.diff(args.path, args.cached, args.files) except pyfedpkg.FedpkgError, e: log.error('Could not diff: %s' % e) sys.exit(1) diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index 9d0865b..cdcde24 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -508,6 +508,34 @@ def delete_tag(tagname=None): _run_command(cmd) log.info ('Tag %s was deleted' % ', '.join(delete)) +def diff(path, 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(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 get_latest_commit(module): """Discover the latest commit has for a given module and return it""" @@ -1192,35 +1220,6 @@ 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.""" -- cgit