mirror of
https://github.com/Balshgit/github_mirror.git
synced 2025-09-11 22:40:44 +03:00
some refactoring and beautify
This commit is contained in:
parent
bb87c1658f
commit
fca67077f5
20
README.md
20
README.md
@ -8,7 +8,7 @@ Use python version > 3.8
|
|||||||
- -h, --help -> ```Show help message and exit```
|
- -h, --help -> ```Show help message and exit```
|
||||||
|
|
||||||
|
|
||||||
- -g GROUP, --group GROUP -> ```Add GROUP id it can be found under group name. Id must be integer```
|
- -g GROUP, --group GROUP -> ```Add repository to GROUP name. It also named Organisation```
|
||||||
|
|
||||||
|
|
||||||
- -u URL [URL ...], --urls URL [URL ...]
|
- -u URL [URL ...], --urls URL [URL ...]
|
||||||
@ -19,9 +19,13 @@ Use python version > 3.8
|
|||||||
```Add file with urls. Each url on new line. Can be combined with --url option. Names will generate automatically from links```
|
```Add file with urls. Each url on new line. Can be combined with --url option. Names will generate automatically from links```
|
||||||
|
|
||||||
- -t TOKEN, --token TOKEN
|
- -t TOKEN, --token TOKEN
|
||||||
```Access token to gitlab API. More information:``` [gitlab docs](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token)
|
```Access token to gitea API. More information:``` [gitea docs](https://docs.gitea.io/en-us/api-usage/#authentication)
|
||||||
|
|
||||||
- -l GITLAB, --gitlab GITLAB ```Provide gitlab url. Default link``` https://git.do.x5.ru
|
- T GITHUBTOKEN, --githubtoken GITHUBTOKEN
|
||||||
|
- ```Please provide github token to get access to private repositories``` [github tokens](https://github.com/settings/tokens)
|
||||||
|
|
||||||
|
|
||||||
|
- -l GITURL, --giturl GITURL ```Provide git url. Default link``` https://git.mywistr.com
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -33,12 +37,12 @@ python3 github_mirror.py [-h] [-g GROUP] (-u URLS [URLS ...] | -f FILE) -t TOKEN
|
|||||||
|
|
||||||
## Examples:
|
## Examples:
|
||||||
|
|
||||||
python3 github_mirror -u "https://github.com/s3rius/FastAPI-template.git" -g 2059 -t "git-QwertY1245kde"
|
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" -g "GitHub" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror -u "https://github.com/s3rius/FastAPI-template.git" "https://github.com/sqlalchemy/sqlalchemy.git" -t "git-QwertY1245kde"
|
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" "https://github.com/sqlalchemy/sqlalchemy.git" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror -f github_mirrors.txt -g 59563 -t "git-QwertY1245kde"
|
python3 github_mirror.py -f github_mirrors.txt -g "Public" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror -f github_mirrors.txt -u "https://github.com/s3rius/FastAPI-template.git" -t "git-QwertY1245kde"
|
python3 github_mirror.py -f github_mirrors.txt -u "https://github.com/s3rius/FastAPI-template.git" -t "gtb-QwertY125kde"
|
||||||
|
|
||||||
python3 github_mirror.py --gitlab "https://gitlab.company.ru" -t "git-QwertY1245kde" -g 2059 -u "https://github.com/s3rius/FastAPI-template.git"
|
python3 github_mirror.py --giturl "https://gitea.company.ru" -t "gtb-QwertY1245kde" -u "https://github.com/Balshgit/sonar-scanner.git" -g "Personal" -T "ghb-Qwerty321ldf"
|
||||||
|
@ -2,18 +2,18 @@ from argparse import ArgumentParser
|
|||||||
|
|
||||||
GIT_URL = 'https://git.mywistr.com'
|
GIT_URL = 'https://git.mywistr.com'
|
||||||
|
|
||||||
USAGE = '''github_mirror [-h] [-g GROUP] (-u URLS [URLS ...] | -f FILE) -t TOKEN
|
USAGE = '''github_mirror [-h] [-g GROUP] (-u URLS [URLS ...] | -f FILE) -t TOKEN [-T GitHubTOKEN]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" -g 2059 -t "glb-QwertY1245kde"
|
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" -g "GitHub" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" "https://github.com/sqlalchemy/sqlalchemy.git" -t "glb-QwertY1245kde"
|
python3 github_mirror.py -u "https://github.com/s3rius/FastAPI-template.git" "https://github.com/sqlalchemy/sqlalchemy.git" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror.py -f github_mirrors.txt -g 59563 -t "glb-QwertY1245kde"
|
python3 github_mirror.py -f github_mirrors.txt -g "Public" -t "gtb-QwertY1245kde"
|
||||||
|
|
||||||
python3 github_mirror.py -f github_mirrors.txt -u "https://github.com/s3rius/FastAPI-template.git" -t "glb-QwertY125kde"
|
python3 github_mirror.py -f github_mirrors.txt -u "https://github.com/s3rius/FastAPI-template.git" -t "gtb-QwertY125kde"
|
||||||
|
|
||||||
python3 github_mirror.py --gitlab "https://gitlab.company.ru" -t "glb-QwertY1245kde" -g Personal -T "ghb-Qwerty321ldf"
|
python3 github_mirror.py --giturl "https://gitea.company.ru" -t "gtb-QwertY1245kde" -u "https://github.com/Balshgit/sonar-scanner.git" -g "Personal" -T "ghb-Qwerty321ldf"
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
@ -28,14 +28,14 @@ def create_parser() -> ArgumentParser:
|
|||||||
"""
|
"""
|
||||||
parser = ArgumentParser(
|
parser = ArgumentParser(
|
||||||
prog='github_mirror',
|
prog='github_mirror',
|
||||||
description='''Script to add mirror repo into gitlab''',
|
description='''Script to add mirror repo into gitea''',
|
||||||
epilog='''the developer is not responsible for the operation of the script :)''',
|
epilog='''the developer is not responsible for the operation of the script :)''',
|
||||||
add_help=True,
|
add_help=True,
|
||||||
usage=USAGE
|
usage=USAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('-g', '--group', required=False, type=str,
|
parser.add_argument('-g', '--group', required=False, type=str,
|
||||||
help='Add group id it can be found under group name. Id must be integer')
|
help='Add repository to GROUP name. It also named Organisation')
|
||||||
|
|
||||||
parser.add_argument('-u', '--urls', nargs='+',
|
parser.add_argument('-u', '--urls', nargs='+',
|
||||||
help='Provide url or urls to mirror with it in format: '
|
help='Provide url or urls to mirror with it in format: '
|
||||||
@ -46,8 +46,8 @@ def create_parser() -> ArgumentParser:
|
|||||||
'--url option. Names will generate automatically from links')
|
'--url option. Names will generate automatically from links')
|
||||||
|
|
||||||
parser.add_argument('-t', '--token', required=True,
|
parser.add_argument('-t', '--token', required=True,
|
||||||
help='Access token to gitlab API. More information: https://docs.gitlab.com/ee/user/profile/'
|
help='Access token to gitea API. More information: https://docs.gitea.io/en-us/api-usage/'
|
||||||
'personal_access_tokens.html#create-a-personal-access-token')
|
'#authentication')
|
||||||
|
|
||||||
parser.add_argument('-T', '--githubtoken', required=False, help='Please provide github token to get access '
|
parser.add_argument('-T', '--githubtoken', required=False, help='Please provide github token to get access '
|
||||||
'to private repositories')
|
'to private repositories')
|
||||||
|
@ -16,7 +16,7 @@ def main():
|
|||||||
# parse urls
|
# parse urls
|
||||||
if args.file:
|
if args.file:
|
||||||
with open(f'{args.file}', mode='r') as file:
|
with open(f'{args.file}', mode='r') as file:
|
||||||
lines = [repo.strip() for repo in file]
|
lines = [line.replace('\n', '').strip() for line in file.readlines()]
|
||||||
mirror_urls.extend(lines)
|
mirror_urls.extend(lines)
|
||||||
if args.urls:
|
if args.urls:
|
||||||
mirror_urls.extend(args.urls)
|
mirror_urls.extend(args.urls)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user