Changes between Version 2 and Version 3 of GitCommit


Ignore:
Timestamp:
06/11/2010 02:45:58 PM (14 years ago)
Author:
damoxc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitCommit

    v2 v3  
    3737GIT_COMMIT       = '/usr/lib/git-core/git-commit' 
    3838GIT_CHECKOUT     = '/usr/lib/git-core/git-checkout' 
    39 GIT_FORMAT_PATCH = '/usr/lib/git-core/git-format-patch' 
     39GIT_CHERRY_PICK  = '/usr/lib/git-core/git-cherry-pick' 
    4040 
    4141if __name__ == '__main__': 
     
    6565            continue 
    6666        current_branch = branch 
    67  
     67     
    6868    # Check to make sure that the provided branches are valid 
    6969    for branch in branches: 
    7070        if branch not in local_branches: 
    71             print >> sys.stderr, 'invalid branch: %s' % branch 
     71            sys.stderr.write('invalid branch: %s\n' % branch) 
    7272            sys.exit(1) 
    7373 
    7474    # Perform the main commit 
    75     subprocess.call([GIT_COMMIT] + git_args) 
     75    p = subprocess.Popen([GIT_COMMIT] + git_args, stdout=subprocess.PIPE) 
     76    if p.wait() > 0: 
     77        sys.stdout.write(p.stdout.read()) 
     78        sys.exit(1) 
     79 
     80    # Get the commit tag without using regex 
     81    try: 
     82        commit_tag = p.stdout.readline().split(' ')[1].split(']')[0] 
     83    except: 
     84        sys.stderr.write('unable to read commit tag\n') 
     85        sys.exit(1) 
    7686 
    7787    # Loop through the specified branches applying the commit to all of 
     
    7989    for branch in branches: 
    8090        subprocess.call([GIT_CHECKOUT, branch]) 
    81         p1 = subprocess.Popen([GIT_FORMAT_PATCH, '-k', '--stdout', '-1', 
    82             current_branch], stdout=subprocess.PIPE) 
    83         p2 = subprocess.Popen([GIT, 'am', '-3', '-k'], stdin=p1.stdout) 
    84         p2.communicate() 
     91        sys.stdout.write('Applying commit %s to %s\n' % (commit_tag, branch)) 
     92        subprocess.call([GIT_CHERRY_PICK, commit_tag], stdout=subprocess.PIPE) 
    8593 
    8694    # Switch back to the original branch