-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.py
More file actions
executable file
·51 lines (44 loc) · 1.55 KB
/
Copy pathgit.py
File metadata and controls
executable file
·51 lines (44 loc) · 1.55 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
######################################################################
#
# This file is used to store functions to create, initialize, and
# add all of a directories contents to github. It is also used to
# update the git repository. If you create a new repo, the name will
# be the same as the directory name.
#
# Author: Trevor Riddle
# Creation Date: May 31, 2017
# Update: NULL
#
######################################################################
import os, sys
##
# Creates, initializes, and adds all directory content to the new
# repo. The repo will be the same name as the directory. It also adds
# a README.md file.
##
def gitinit():
os.system("curl -u riddletd https://api.github.com/user/repos -d \'{ \"name\": \"" + gitRepoName() + "\" }\'")
os.system("echo \"# " + gitRepoName() + "\" >> README.md")
os.system("git init")
os.system("git add README.md")
os.system("git commit -m \"first commit\"")
os.system("git remote add origin https://github.com/riddletd/" + gitRepoName() + ".git")
os.system("git push -u origin master")
gitput()
##
# Cleans the directory content of auto-save files, adds them to the
# repo, commit's them with a timestamp, and pushes the content.
##
def gitput():
os.system("rm *~")
os.system("rm *#")
os.system("git add *")
os.system("git commit -m \"Update: `date +'%Y-%m-%d %H:%M:%S'`\"")
os.system("git push")
##
# Get's the current directory name to be used to create the new repo.
##
def gitRepoName():
str = os.path.split(os.getcwd())
return str[1]