Skip to content

Commit

Permalink
Added git pull
Browse files Browse the repository at this point in the history
  • Loading branch information
LaserPhaser committed Sep 28, 2020
1 parent 8bf8ff5 commit 94c8170
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Example
└── subgroup2
└── subgroup3

If you will use this command again `gitlab-clone` will just pull the updated to the existing repos, and will download new repos from the group.


.. _`pip`: https://pypi.python.org/pypi/pip/
16 changes: 11 additions & 5 deletions gitlab_clone/clonner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import requests
import subprocess, shlex
import argparse
import os
import logging


def main():
Expand All @@ -15,6 +17,7 @@ def main():

parser.add_argument('--gitlab-url', metavar='gitlab', type=str,
help='Gitlab address [by default gitlab.com]', default='gitlab.com')

args = parser.parse_args()
request_param = args.__dict__

Expand All @@ -31,14 +34,17 @@ def clone(group_id, branch, token, gitlab_url):
for project in response.json():
path = project['path_with_namespace']
ssh_url_to_repo = project['ssh_url_to_repo']

try:

command = shlex.split(f"git clone --branch {branch} {ssh_url_to_repo} {path}")
result_code = subprocess.Popen(command)
if not os.path.exists(path):
command = shlex.split(f"git clone --branch {branch} {ssh_url_to_repo} {path}")
result_code = subprocess.Popen(command)
else:
logging.info(f"{path} already exists")
command = shlex.split(f"cd {path}; git pull {path}; cd -")
result_code = subprocess.Popen(command)

except Exception as e:
print(f"Error on {ssh_url_to_repo}: {e}")
logging.error(f"Error on {ssh_url_to_repo}: {e}")

total_pages = int(response.headers['X-Total-Pages'])

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.2
current_version = 1.1.0
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/ArseniyAntonov/gitlab-group-clone',
version='1.0.2',
version='1.1.0',
entry_points={
"console_scripts": [
"gitlab-clone=gitlab_clone.clonner:main",
Expand Down

0 comments on commit 94c8170

Please sign in to comment.