-
Notifications
You must be signed in to change notification settings - Fork 15
/
addFile.py
executable file
·29 lines (26 loc) · 920 Bytes
/
addFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Python 3
import os
import sys
if(len(sys.argv) == 3):
repoDir = sys.argv[1]
solutionPath = sys.argv[2]
else:
print ("Invalid command line arguments, please run: addFile.py [absolute path of directory containing student repositories] [absolute path of solution]")
sys.exit(0)
if(repoDir.endswith('/')):
levels = repoDir.count('/') + 1
else:
levels = repoDir.count('/') + 2
for subdir in os.walk(repoDir):
for i in subdir:
if type(i) == str:
if len(i.split("/")) == levels:
print(i)
os.chdir(i)
os.system("git checkout master")
os.system("git pull")
copyCmd = "cp {} {}".format(solutionPath, i)
os.system(copyCmd)
os.system("git add .")
os.system("git commit -m \"Add additional assignment document\"")
os.system("git push")