Created
November 22, 2013 00:48
-
-
Save tarmstrong/7592751 to your computer and use it in GitHub Desktop.
Cause a merge conflict!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tavish Armstrong (c) 2013 | |
# | |
# make_merge_conflict.py | |
# | |
# Make a new directory, initialize a git repository within, and cause a merge conflict. | |
# Yes. On purpose. | |
import os | |
import subprocess | |
import random | |
import hashlib | |
randpart = hashlib.sha1(str(random.random())).hexdigest()[:4] | |
folder_name = "merge-conflict-testfolder-{}".format(randpart) | |
os.mkdir(folder_name) | |
os.chdir(folder_name) | |
print subprocess.check_output('git init'.split()) | |
with open('test.txt', 'w') as f: | |
f.write("\n".join("123456")) | |
print subprocess.check_output('git add test.txt'.split()) | |
print subprocess.check_output(['git', 'commit', '-am', '"Base commit"']) | |
print subprocess.check_output('git checkout -b your-friends-branch'.split()) | |
with open('test.txt', 'w') as f: | |
f.write("\n".join("133456")) | |
print subprocess.check_output(['git', 'commit', '-am', '"Friend commit"']) | |
print subprocess.check_output('git checkout master'.split()) | |
with open('test.txt', 'w') as f: | |
f.write("\n".join("173456")) | |
print subprocess.check_output(['git', 'commit', '-am', '"My commit"']) | |
print subprocess.check_output('git merge your-friends-branch'.split()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment