mirror of
https://github.com/varunsridharan/github-gitea-mirror.git
synced 2024-09-11 17:56:39 +03:00
Created Trigger From Common File
This commit is contained in:
parent
ce21ce66b1
commit
25b90bd894
@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig, giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser
|
||||
config = getConfig()
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
default_gist_user = giteaGetUser('gist')
|
||||
if default_gist_user == 'failed':
|
||||
default_gist_user = giteaCreateOrg('gist')
|
||||
|
||||
|
||||
for repo in gh.get_user().get_gists():
|
||||
if repo.public:
|
||||
isPrivate = False
|
||||
else:
|
||||
isPrivate= True
|
||||
|
||||
print('Gist : {0}/{1}'.format(repo.owner.login,repo.id))
|
||||
|
||||
prefix = ''
|
||||
surfix = ''
|
||||
gitea_uid = giteaGetUser(repo.owner.login)
|
||||
repo_owner = repo.owner.login
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(repo.owner.login)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = default_gist_user
|
||||
repo_owner = 'gist'
|
||||
|
||||
if len(config['gitea']['gist']['prefix']) != 0:
|
||||
prefix = "{0}-".format(config['gitea']['gist']['prefix'])
|
||||
|
||||
if len(config['gitea']['gist']['surfix']) != 0:
|
||||
surfix = "-{0}".format(config['gitea']['gist']['surfix'])
|
||||
|
||||
m = {
|
||||
"repo_name" : "{0}{1}{2}".format(prefix,repo.id,surfix),
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.git_pull_url,
|
||||
"mirror" : True,
|
||||
"private" : isPrivate,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
status = giteaCreateRepo(m,isPrivate)
|
||||
|
||||
if status == 'created':
|
||||
topics = ['gist','{0}-gist'.format(repo_owner)]
|
||||
if isPrivate:
|
||||
topics.append('secret-gist')
|
||||
topics.append('secret-{0}-gist'.format(repo_owner))
|
||||
else:
|
||||
topics.append('public-gist')
|
||||
topics.append('public-{0}-gist'.format(repo_owner))
|
||||
giteaSetRepoTopics(repo_owner,m["repo_name"],topics)
|
||||
|
||||
print(" ")
|
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig,giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser,config
|
||||
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
for repo in gh.get_user().get_repos():
|
||||
if not repo.fork:
|
||||
real_repo = repo.full_name.split('/')[1]
|
||||
gitea_dest_user = repo.owner.login
|
||||
repo_owner=repo.owner.login
|
||||
|
||||
print('Source Repository : {0}'.format(repo.full_name))
|
||||
|
||||
if real_repo in repo_map:
|
||||
gitea_dest_user = repo_map[real_repo]
|
||||
|
||||
gitea_uid = giteaGetUser(gitea_dest_user)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(gitea_dest_user)
|
||||
|
||||
repo_name = "{0}".format(real_repo)
|
||||
|
||||
m = {
|
||||
"repo_name" : repo_name,
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.clone_url,
|
||||
"mirror" : True,
|
||||
"private" : repo.private,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
giteaCreateRepo(m,repo.private)
|
||||
topics = repo.get_topics()
|
||||
giteaSetRepoTopics(repo_owner,repo_name,topics)
|
||||
print(" ")
|
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig,giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser,config
|
||||
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
for repo in gh.get_user().get_starred():
|
||||
real_repo = repo.full_name.split('/')[1]
|
||||
gitea_dest_user = repo.owner.login
|
||||
repo_owner=repo.owner.login
|
||||
|
||||
print('⭐ Star\'ed Repository : {0}'.format(repo.full_name))
|
||||
|
||||
if real_repo in repo_map:
|
||||
gitea_dest_user = repo_map[real_repo]
|
||||
|
||||
gitea_uid = giteaGetUser(gitea_dest_user)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(gitea_dest_user)
|
||||
|
||||
repo_name = "{0}".format(real_repo)
|
||||
|
||||
m = {
|
||||
"repo_name" : repo_name,
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.clone_url,
|
||||
"mirror" : True,
|
||||
"private" : repo.private,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
giteaCreateRepo(m,repo.private)
|
||||
topics = repo.get_topics()
|
||||
giteaSetRepoTopics(repo_owner,repo_name,topics)
|
||||
print(" ")
|
24
mirror.py
Normal file
24
mirror.py
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
from helper import getConfig
|
||||
from sourceGist import sourceGist
|
||||
from repositorySource import repositorySource
|
||||
from repositoryStared import repositoryStared
|
||||
from repositoryForked import repositoryForked
|
||||
|
||||
config = getConfig()
|
||||
|
||||
if config['gist']:
|
||||
print('Setting Up Mirror For Github Gists')
|
||||
sourceGist()
|
||||
|
||||
if config['repositorySource']:
|
||||
print('Setting Up Mirror For Source Github Repository')
|
||||
#repositorySource()
|
||||
|
||||
if config['repositoryStared']:
|
||||
print('Setting Up Mirror For Stared Github Repository')
|
||||
#repositoryStared()
|
||||
|
||||
if config['repositoryForked']:
|
||||
print('Setting Up Mirror For Forked Github Repository')
|
||||
#repositoryForked()
|
41
repositoryForked.py
Normal file
41
repositoryForked.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig,giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser,config
|
||||
|
||||
def repositoryForked():
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
for repo in gh.get_user().get_repos():
|
||||
if repo.fork:
|
||||
real_repo = repo.full_name.split('/')[1]
|
||||
gitea_dest_user = repo.owner.login
|
||||
repo_owner=repo.owner.login
|
||||
|
||||
print('Forked Repository : {0}'.format(repo.full_name))
|
||||
|
||||
if real_repo in repo_map:
|
||||
gitea_dest_user = repo_map[real_repo]
|
||||
|
||||
gitea_uid = giteaGetUser(gitea_dest_user)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(gitea_dest_user)
|
||||
|
||||
repo_name = "{0}".format(real_repo)
|
||||
|
||||
m = {
|
||||
"repo_name" : repo_name,
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.clone_url,
|
||||
"mirror" : True,
|
||||
"private" : repo.private,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
giteaCreateRepo(m,repo.private)
|
||||
topics = repo.get_topics()
|
||||
giteaSetRepoTopics(repo_owner,repo_name,topics)
|
||||
print(" ")
|
41
repositorySource.py
Normal file
41
repositorySource.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig,giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser,config
|
||||
|
||||
def repositorySource():
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
for repo in gh.get_user().get_repos():
|
||||
if not repo.fork:
|
||||
real_repo = repo.full_name.split('/')[1]
|
||||
gitea_dest_user = repo.owner.login
|
||||
repo_owner=repo.owner.login
|
||||
|
||||
print('Source Repository : {0}'.format(repo.full_name))
|
||||
|
||||
if real_repo in repo_map:
|
||||
gitea_dest_user = repo_map[real_repo]
|
||||
|
||||
gitea_uid = giteaGetUser(gitea_dest_user)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(gitea_dest_user)
|
||||
|
||||
repo_name = "{0}".format(real_repo)
|
||||
|
||||
m = {
|
||||
"repo_name" : repo_name,
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.clone_url,
|
||||
"mirror" : True,
|
||||
"private" : repo.private,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
giteaCreateRepo(m,repo.private)
|
||||
topics = repo.get_topics()
|
||||
giteaSetRepoTopics(repo_owner,repo_name,topics)
|
||||
print(" ")
|
@ -2,18 +2,18 @@
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig,giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser,config
|
||||
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
def repositoryStared():
|
||||
config = getConfig()
|
||||
repo_map = config['repomap']
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
for repo in gh.get_user().get_repos():
|
||||
if repo.fork:
|
||||
for repo in gh.get_user().get_starred():
|
||||
real_repo = repo.full_name.split('/')[1]
|
||||
gitea_dest_user = repo.owner.login
|
||||
repo_owner=repo.owner.login
|
||||
|
||||
print('Forked Repository : {0}'.format(repo.full_name))
|
||||
print('⭐ Star\'ed Repository : {0}'.format(repo.full_name))
|
||||
|
||||
if real_repo in repo_map:
|
||||
gitea_dest_user = repo_map[real_repo]
|
62
sourceGist.py
Normal file
62
sourceGist.py
Normal file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python
|
||||
# https://github.com/PyGithub/PyGithub
|
||||
from helper import getConfig, giteaSetRepoTopics,giteaSession,giteaCreateRepo,ghApi,giteaCreateOrg,giteaGetUser
|
||||
|
||||
def sourceGist():
|
||||
config = getConfig()
|
||||
session = giteaSession()
|
||||
gh = ghApi()
|
||||
|
||||
default_gist_user = giteaGetUser('gist')
|
||||
if default_gist_user == 'failed':
|
||||
default_gist_user = giteaCreateOrg('gist')
|
||||
|
||||
|
||||
for repo in gh.get_user().get_gists():
|
||||
if repo.public:
|
||||
isPrivate = False
|
||||
else:
|
||||
isPrivate= True
|
||||
|
||||
print('Gist : {0}/{1}'.format(repo.owner.login,repo.id))
|
||||
|
||||
prefix = ''
|
||||
surfix = ''
|
||||
gitea_uid = giteaGetUser(repo.owner.login)
|
||||
repo_owner = repo.owner.login
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = giteaCreateOrg(repo.owner.login)
|
||||
|
||||
if gitea_uid == 'failed':
|
||||
gitea_uid = default_gist_user
|
||||
repo_owner = 'gist'
|
||||
|
||||
if len(config['gitea']['gist']['prefix']) != 0:
|
||||
prefix = "{0}-".format(config['gitea']['gist']['prefix'])
|
||||
|
||||
if len(config['gitea']['gist']['surfix']) != 0:
|
||||
surfix = "-{0}".format(config['gitea']['gist']['surfix'])
|
||||
|
||||
m = {
|
||||
"repo_name" : "{0}{1}{2}".format(prefix,repo.id,surfix),
|
||||
"description" : (repo.description or "not really known")[:255],
|
||||
"clone_addr" : repo.git_pull_url,
|
||||
"mirror" : True,
|
||||
"private" : isPrivate,
|
||||
"uid" : gitea_uid,
|
||||
}
|
||||
|
||||
status = giteaCreateRepo(m,isPrivate)
|
||||
|
||||
if status == 'created':
|
||||
topics = ['gist','{0}-gist'.format(repo_owner)]
|
||||
if isPrivate:
|
||||
topics.append('secret-gist')
|
||||
topics.append('secret-{0}-gist'.format(repo_owner))
|
||||
else:
|
||||
topics.append('public-gist')
|
||||
topics.append('public-{0}-gist'.format(repo_owner))
|
||||
giteaSetRepoTopics(repo_owner,m["repo_name"],topics)
|
||||
|
||||
print(" ")
|
Loading…
Reference in New Issue
Block a user