Last active
August 29, 2015 14:16
-
-
Save hG3n/7a3bf85252ee0f0f5027 to your computer and use it in GitHub Desktop.
script to add argument files and commt them with a specific message
This file contains 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
#!/usr/bin/env python | |
import sys | |
import os | |
from subprocess import call | |
# get arguments to array | |
args = sys.argv | |
args.pop(0); | |
# get list of files in directories | |
src = os.listdir('src/') | |
inc = os.listdir('inc/') | |
# checks if argument is inside | |
# the list of src and inc folders | |
def argInList(arg,ext,list): | |
filename = arg+ext | |
for i in range(0, len(list)): | |
if filename == list[i]: | |
return True | |
# if argument is sourcefile or header | |
# add files and commit changes | |
for i in range(0, len(args)): | |
if argInList(args[i],'.cpp',src): | |
source = 'src/'+args[i]+'.cpp' | |
if argInList(args[i], '.h', inc): | |
header = 'inc/'+args[i]+'.h' | |
call(['git','add',source,header]) | |
print 'added:',source,header | |
message = raw_input('Commit Message: ') | |
call(['git','commit','-m',message]) | |
else: | |
call(['git','add',source]) | |
print 'added:',source | |
message = raw_input('Commit Message: ') | |
call(['git','commit','-m',message]) | |
else: | |
print 'there were no files to commit' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment