Skip to content

Commit

Permalink
v2.1.1 - bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Jul 15, 2020
1 parent 2c57d36 commit 5ffdcca
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 2.1.1 (2020-07-14)

* Fixed the long argument names which had underscores intead of hyphens
* Fixed a bug where threads were not waiting at the end of the script before printing the completion message

## 2.1.0 (2020-07-01)

* Replaced `requirements.txt` with `setup.py`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
A powerful script to concurrently clone your entire GitHub instance or save it as an archive.

[![Build Status](https://travis-ci.com/Justintime50/github-archive.svg?branch=master)](https://travis-ci.com/Justintime50/github-archive)
[![Pypi](https://img.shields.io/pypi/v/github-archive)](https://pypi.org/project/github-archive)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

<img src="assets/showcase.gif">
Expand Down
56 changes: 34 additions & 22 deletions githubarchive/github_archive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Import modules"""
# pylint: disable=W0511,R0912,R0915
# TODO: Restructure the code to align with what Pylint wants ^
# pylint: disable=R0912,R0915
import os
from datetime import datetime
import sys
Expand All @@ -17,17 +16,17 @@ class Archive():
parser = argparse.ArgumentParser(
description='A powerful script to concurrently clone your entire' +
'GitHub instance or save it as an archive.')
parser.add_argument('-uc', '--user_clone', action='store_true',
parser.add_argument('-uc', '--user-clone', action='store_true',
help='Clone personal repos.')
parser.add_argument('-up', '--user_pull', action='store_true',
parser.add_argument('-up', '--user-pull', action='store_true',
help='Pull personal repos')
parser.add_argument('-gc', '--gists_clone', action='store_true',
parser.add_argument('-gc', '--gists-clone', action='store_true',
help='Clone personal gists')
parser.add_argument('-gp', '--gists_pull', action='store_true',
parser.add_argument('-gp', '--gists-pull', action='store_true',
help='Pull personal gists.')
parser.add_argument('-oc', '--orgs_clone', action='store_true',
parser.add_argument('-oc', '--orgs-clone', action='store_true',
help='Clone organization repos.')
parser.add_argument('-op', '--orgs_pull', action='store_true',
parser.add_argument('-op', '--orgs-pull', action='store_true',
help='Pull organization repos.')
parser.add_argument('-b', '--branch', default='master',
help='Which branch to pull from.')
Expand Down Expand Up @@ -153,6 +152,7 @@ def main():
preamble = f'{start_message}\n{start_time}\n'
print(preamble)
Archive.logs(preamble)
thread_list = []

# Iterate over each personal repo and concurrently start cloning
if Archive.args.user_clone is True:
Expand All @@ -164,8 +164,10 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'repos', repo.owner.login, repo.name)
Thread(target=Archive.clone_repos, args=(
repo, path,)).start()
repo_thread = Thread(target=Archive.clone_repos, args=(
repo, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping cloning user repos... ##'
print(data)
Expand All @@ -181,8 +183,10 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'repos', repo.owner.login, repo.name)
Thread(target=Archive.pull_repos, args=(
repo, path,)).start()
repo_thread = Thread(target=Archive.pull_repos, args=(
repo, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping pulling user repos...## '
print(data)
Expand All @@ -197,8 +201,10 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'gists', gist.id)
Thread(target=Archive.clone_gists, args=(
gist, path,)).start()
repo_thread = Thread(target=Archive.clone_gists, args=(
gist, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping cloning gists... ##'
print(data)
Expand All @@ -213,8 +219,10 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'gists', gist.id)
Thread(target=Archive.pull_gists, args=(
gist, path,)).start()
repo_thread = Thread(target=Archive.pull_gists, args=(
gist, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping pulling gists... ##'
print(data)
Expand All @@ -238,8 +246,10 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'repos', repo.owner.login, repo.name)
Thread(target=Archive.clone_repos, args=(
repo, path,)).start()
repo_thread = Thread(target=Archive.clone_repos, args=(
repo, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping cloning org repos... ##'
print(data)
Expand All @@ -257,15 +267,17 @@ def main():
time.sleep(Archive.BUFFER)
path = os.path.join(
Archive.LOCATION, 'repos', repo.owner.login, repo.name)
Thread(target=Archive.pull_repos, args=(
repo, path,)).start()
repo_thread = Thread(target=Archive.pull_repos, args=(
repo, path,))
thread_list.append(repo_thread)
repo_thread.start()
else:
data = '## Skipping pulling org repos... ##'
print(data)
Archive.logs(data)

# TODO: Use threading.wait to check if all processes are finished
time.sleep(6)
for thread in thread_list:
thread.join()
execution_time = f'Execution time: {datetime.now() - start_time}.'
finish_message = f'GitHub Archive complete! {execution_time}'
print(finish_message)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name='github-archive',
version='2.1.0',
version='2.1.1',
description='A powerful script to concurrently clone your entire GitHub instance or save it as an archive.',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 5ffdcca

Please sign in to comment.