类似于git状态的命令(或脚本)显示自上次git svn dcommit以来的所有本地提交? [英] Command (or script) similar to git status to show all local commits since last git svn dcommit?
问题描述
这个python脚本是迄今为止最好的。我只是一起闯入并在第一对夫妇中使用,似乎是正确行事,但我不禁感到有一种更简单的方法可以做到这一点,甚至是内置的东西(尽管我已经搜索和搜索)。 / p>
感谢您的帮助。
#!/ usr / bin / env python
import sys
import subprocess
s = subprocess.Popen(git svn log --show-commit --oneline.split(),
stdout = subprocess.PIPE)
#获取最后的svn提交的数据
revision,sha,message = s.stdout.readlines()。pop(0).split(|)
#从svn rebase获取提交显示
s = subprocess.Popen((git log%s..HEAD --oneline%sha).split(),
stdout = subprocess.PIPE)
log = s.stdout.read()。st rip()
如果len(log.splitlines())> 0:
print(%d提交svn。要将它们推送到svn,请使用'git svn dcommit'。\ n
%len(log.splitlines()))
打印日志
else:
printNo本地提交需要'git svn dcommit'
sys.exit(0)
<首先,执行 git branch -a
来列出所有远程分支:
$ git branch -a
git-svn
对我来说,只有 git-svn
分支已被列出,但您可能会有不同的名称,具体取决于您传递给 git svn clone
的选项。然后,使用
git log git-svn ..
(用 git-svn
替换相应的名称)。上面的命令(注意两个结尾点<$ c $自从当前分支的最近的共同祖先和之后,显示当前分支上的所有提交> git-svn
分支。
This python script is the best I have come up with so far. I just hacked it together and on a cursory first couple uses, seems to be acting correctly, but I can't help but feel there is an easier way to do this or even something built in (though I have searched and searched).
Thanks for the help.
#!/usr/bin/env python import sys import subprocess s = subprocess.Popen("git svn log --show-commit --oneline".split(" "), stdout=subprocess.PIPE) # Grab the last svn commit's data revision, sha, message = s.stdout.readlines().pop(0).split(" | ") # Grab display of commits since svn rebase s = subprocess.Popen(("git log %s..HEAD --oneline" % sha).split(" "), stdout=subprocess.PIPE) log = s.stdout.read().strip() if len(log.splitlines()) > 0: print ("%d commits ahead of svn. To push them to svn, use 'git svn dcommit'.\n" % len(log.splitlines())) print log else: print "No local commits that need 'git svn dcommit'" sys.exit(0)
First, do a git branch -a
to list all the remote branches:
$ git branch -a
git-svn
For me, only the git-svn
branch is listed, but you may have different names depending on what options you passed to git svn clone
. Then, use
git log git-svn..
(substituting your appropriate name for git-svn
). The above command (note the two trailing dots ..
) shows all the commits on the current branch since the nearest common ancestor of the current branch and the git-svn
branch.
这篇关于类似于git状态的命令(或脚本)显示自上次git svn dcommit以来的所有本地提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!