Skip to content

Instantly share code, notes, and snippets.

@mikeblum
Created March 17, 2017 14:30
Show Gist options
  • Save mikeblum/9dab01a90845b1bd93c3de92a12714c0 to your computer and use it in GitHub Desktop.
Save mikeblum/9dab01a90845b1bd93c3de92a12714c0 to your computer and use it in GitHub Desktop.
Create an authors.txt file for migrating from SVN to GIT using svn2git
import argparse
import subprocess
import sys
def main():
'''
Parse all SVN authors from the repository and append the specified domain
'''
parser = argparse.ArgumentParser(description='Collate all SVN comitters / authors with an email address.')
parser.add_argument('-domain', metavar='-d', help='e.x. tsgrp.com')
args = parser.parse_args()
domain = args.domain
authors_file = open('authors.txt', 'w')
proc = subprocess.Popen("svn log | grep r[0-9].*$ | awk '{print $3}' | sort | uniq", shell=True, stdout=subprocess.PIPE)
template = '{author} = {author} <{author}@{domain}>\n'
authors = author=proc.stdout.read().splitlines()
for author in authors:
# encode the bytes as UTF-8
author = str(author, 'utf-8')
if author is '':
continue
print(template.format(author=author, domain=domain))
authors_file.write(template.format(author=author, domain=domain))
authors_file.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment