Skip to content

Instantly share code, notes, and snippets.

@hG3n
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hG3n/7a3bf85252ee0f0f5027 to your computer and use it in GitHub Desktop.
Save hG3n/7a3bf85252ee0f0f5027 to your computer and use it in GitHub Desktop.
script to add argument files and commt them with a specific message
#!/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