aboutsummaryrefslogtreecommitdiff
path: root/update_mirrors.py
diff options
context:
space:
mode:
authorgit user <git@git.suspectdevices.com>2026-08-06 23:22:15 -0700
committergit user <git@git.suspectdevices.com>2026-08-06 23:22:15 -0700
commit97086e489db4e4b99a21fe3ad52f06917f39e482 (patch)
treea639d9d01c7d121204c032fab399309ee6fabe64 /update_mirrors.py
parent261ddb54e04a36598b5b3b4303993195d081a484 (diff)
short namesHEADmain
Diffstat (limited to 'update_mirrors.py')
-rwxr-xr-xupdate_mirrors.py63
1 files changed, 43 insertions, 20 deletions
diff --git a/update_mirrors.py b/update_mirrors.py
index c5a56e3..e5ce1d8 100755
--- a/update_mirrors.py
+++ b/update_mirrors.py
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
+
+
+
import os
import subprocess
from github import Github
@@ -23,27 +26,47 @@ def myrepos() :
g.close()
return(repos)
+#repo.url=wcm
+#repo.owner=yctct
+#repo.path=/home/git/repositories/wcm.git
+#repo.desc= a script to count words in Markdown files
+#
+# Consider sorting by prefix and making group entries
if __name__ == "__main__":
local_prefix="/srv/git/mirrors/github/"
-
- for url in myrepos():
- #print(url)
- local_copy=local_prefix+url.split(':')[1]
- if os.path.isdir(local_copy):
- print("updating local copy: " + local_copy)
- result=subprocess.run(["git", "remote", "update"],
- cwd=local_copy, capture_output=True)
- print(result.stdout.decode(), end='')
- print(result.stderr.decode(), end='')
- else:
- print("create new mirror at: "+local_copy)
- result=subprocess.run(["git","clone","--mirror", url,
- local_copy], capture_output=True)
- print(result.stdout.decode(), end='')
- print(result.stderr.decode(), end='')
-
- #print(local_copy)
- #mypath="/srv/git/mirrors/github/"+repo.ssh_url.split(':')[1]
- #print("git clone --mirror " +repo.ssh_url+" "+mypath)
+ g = mygithub()
+ with open("/srv/git/repolist", "w") as repolist:
+
+ for repo in g.get_user().get_repos():
+ url=repo.ssh_url
+ shortname = url.split(':')[1].split('.')[0]
+ local_copy=local_prefix+url.split(':')[1]
+
+ repolist.write("repo.url="+shortname+"\n")
+ # repolist.write("repo.url="+url+"\n")
+ repolist.write("repo.owner=feurig\n")
+ repolist.write("repo.path="+local_copy+"\n")
+ description = repo.description
+ if repo.description is None:
+ description = "No Description Provided"
+ repolist.write("repo.desc="+description+"\n")
+
+ if os.path.isdir(local_copy):
+ print("updating local copy: " + local_copy)
+ result=subprocess.run(["git", "remote", "update"],
+ cwd=local_copy, capture_output=True)
+ print(result.stdout.decode(), end='')
+ print(result.stderr.decode(), end='')
+ else:
+ print("create new mirror at: "+local_copy)
+ result=subprocess.run(["git","clone","--mirror", url,
+ local_copy], capture_output=True)
+ print(result.stdout.decode(), end='')
+ print(result.stderr.decode(), end='')
+
+ #print(local_copy)
+ #mypath="/srv/git/mirrors/github/"+repo.ssh_url.split(':')[1]
+ #print("git clone --mirror " +repo.ssh_url+" "+mypath)
+ g.close()
\ No newline at end of file