Changeset 459


Ignore:
Timestamp:
08-01-10 17:56:56 (3 years ago)
Author:
thomas
Message:

patch by: Jan Urbanski

  • moap/vcs/git.py: support added and deleted files in Git. Fixes #413.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r456 r459  
     12010-01-08  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        patch by: Jan Urbanski 
     4 
     5        * moap/vcs/git.py: 
     6          support added and deleted files in Git. 
     7          Fixes #413. 
     8 
    192009-12-28  Thomas Vander Stichele  <thomas at apestaart dot org> 
    210 
  • trunk/moap/vcs/git.py

    r419 r459  
    4646        os.chdir(oldPath) 
    4747        return result 
     48 
     49    def _getByStatus(self, path, status): 
     50        ret = [] 
     51        oldPath = os.getcwd() 
     52 
     53        os.chdir(path) 
     54        cmd = "git diff --cached --diff-filter=%s --raw" % status 
     55        output = commands.getoutput(cmd) 
     56        lines = output.split("\n") 
     57         
     58        matcher = re.compile(r'^:.*\.\.\. ' + status + '\s+(.*)') 
     59        for l in lines: 
     60            m = matcher.search(l) 
     61            if m: 
     62                relpath = m.expand("\\1") 
     63                ret.append(relpath) 
     64 
     65        # FIXME: would be nice to sort per directory 
     66        os.chdir(oldPath) 
     67        return ret 
     68 
     69    def getAdded(self, path): 
     70        return self._getByStatus(path, 'A') 
     71 
     72    def getDeleted(self, path): 
     73        return self._getByStatus(path, 'D') 
    4874 
    4975    def ignore(self, paths, commit=True): 
     
    103129            self.debug('frobnicated path to %s' % path) 
    104130 
    105         cmd = "git diff --cached -- %s" % path 
     131        cmd = "git diff --cached --diff-filter=M -- %s" % path 
    106132        self.debug("Running %s" % cmd) 
    107133        output = commands.getoutput(cmd) 
Note: See TracChangeset for help on using the changeset viewer.