-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
67 lines (52 loc) · 1.94 KB
/
index.py
File metadata and controls
67 lines (52 loc) · 1.94 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import requests
import json
import os
from subprocess import call, Popen, PIPE
def fake_repository(url, username):
print("Faking " + url)
git_url = 'https://github.com/' + username + '/' + url + '.git'
os.system('git clone ' + git_url) # clone
os.chdir(url)
os.system('git branch -M main')
os.system("""
git filter-branch -f --env-filter \
"GIT_AUTHOR_NAME='{}'\
GIT_AUTHOR_EMAIL='{}'\
GIT_COMMITTER_NAME='{}'\
GIT_COMMITTER_EMAIL='{}'\
" HEAD\
""".format(g_name, g_email, g_name, g_email))
os.chdir('../')
print("Success fake " + url)
def push_repository(url):
print("Pushing " + url)
os.chdir(url)
os.system('gh repo create {} --public'.format(url))
os.system('git remote remove origin')
os.system('git remote add origin https://github.com/{}/{}'.format(g_name, url))
os.system('git config user.name {}'.format(g_name))
os.system('git config user.email {}'.format(g_email))
os.system('git push -u origin main')
os.chdir('../')
print("Success push " + url)
if __name__ == '__main__':
#response = requests.get('https://api.github.com/users/gitusername/repos')
#repositories = json.loads(response.text)
# g_name = input('Enter your github user name: ')
# g_email = input('Enter your github user email: ')
# g_name = 'supervenus0204'
# g_email = 'supervenus0204@gmail.com'
g_name = 'robertjacks'
g_email = 'robertjacks0204@gmail.com'
f = open("need_unfork.txt", "r", encoding='utf8')
repositories = f.readlines()
print(repositories)
for repo in repositories:
url_list = repo.split("/")
print(url_list)
url = url_list[4].replace("\n", "")
username = url_list[3].replace("\n", "")
print(url)
fake_repository(url, username)
push_repository(url)
f.close()