非常感谢对这个问题的反馈
import subprocess
def main():
'''
Here's where the whole thing starts.
'''
#Edit this constant to change the file name in the git log command.
FILE_NAME = 'file1.xml'
#Do the git describe command to get the tag names.
gitDescribe = 'git describe --tags `git rev-list --tags --max-count=2`'
print ('Invoking: {0}'.format(gitDescribe))
p1 = subprocess.Popen(gitDescribe, shell=True, stdout=subprocess.PIPE)
output = p1.stdout.read()
#Get the first 2 tags from the output.
parsedOutput = output.split('\n')
tag1 = parsedOutput[0]
tag2 = parsedOutput[1]
print('First revision: {0}'.format(tag1))
print('Second …Run Code Online (Sandbox Code Playgroud) python ×1