python 用于git的脚本

来源:互联网 发布:展板设计软件下载 编辑:程序博客网 时间:2024/05/21 10:22
'''Readmepython commitmessage.py 19.3.A.0.12 19.3.A.0.13oldtag:19.3.A.0.12 newtag:19.3.A.0.13'''import osimport os.pathimport stringimport sysimport commandsclass ParseCommit:   def parse(self,alldms,commit):       self.dms = -1       self.changeid = -1       title = " - "+commit[4].lstrip()       if ( len(title) > 70):           title = title + "<<<<<<<<too long"       print " - "+commit[4].lstrip(),       for line in commit:           if line.find("FIX=") != -1:                self.dms = line                alldms.append(line.lstrip())                #print line.lstrip()                continue           if line.find("Change-Id:") != -1:                self.changeid = line                print "   "+line.lstrip(),                continue                 #oldtag="19.3.A.0.12"#newtag="19.3.A.0.13"oldtag=sys.argv[1]newtag=sys.argv[2]#print "oldtag:"+oldtag#print "newtag:"+newtagcmd_gitallsh1 = "git log --pretty=%H " + oldtag + ".." + newtagcmd_gitalltile = "git log --pretty=%s " + oldtag + ".." + newtagcmd_gitsh1 = "git log -1 "alldms = []count = 0'''stream = os.popen(cmd_gitallsh1)allsh1 = stream.readlines()parse = ParseCommit();print cmd_gitsh1 + allsh1[0]stream = os.popen(cmd_gitsh1 + allsh1[0])commit = stream.readlines()parse.parse(alldms,commit);'''print "Delivery of " + newtagprintprint "includes:"stream = os.popen(cmd_gitallsh1)allsh1 = stream.readlines()parse = ParseCommit();for sh1 in allsh1:    #print sh1    stream = os.popen(cmd_gitsh1+sh1)    commit = stream.readlines()    parse.parse(alldms,commit);print printprint for dms in alldms:        print dms,      

提取两个tag之间的commit message的信息
0 0
原创粉丝点击