Skip to content

Commit

Permalink
v2.1.2 - closes #13, fixing script entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Aug 15, 2020
1 parent 5ffdcca commit eb35198
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.1.2 (2020-8-14)

* Fixed the script's entrypoint (PyPi installs work again)

## 2.1.1 (2020-07-14)

* Fixed the long argument names which had underscores intead of hyphens
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A powerful script to concurrently clone your entire GitHub instance or save it a
[![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">
<img src="assets/showcase.gif" alt="Showcase">

</div>

Expand Down Expand Up @@ -62,7 +62,7 @@ Basic Usage:
Advanced Usage:
GITHUB_ARCHIVE_TOKEN=123... GITHUB_ARCHIVE_ORGS="org1, org2" GITHUB_ARCHIVE_LOCATION="~/custom_location" \
github_archive -uc -up -gc -gp -oc -op -b develop
github-archive -uc -up -gc -gp -oc -op -b develop
Options:
-uc, --user-clone Clone personal repos (default: on)
Expand Down
Empty file added githubarchive/__init__.py
Empty file.
86 changes: 61 additions & 25 deletions githubarchive/github_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,63 @@


class Archive():
"""All GitHub Archive methods"""
# Setup arguments
"""All GitHub Archive methods
"""
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',
help='Clone personal repos.')
parser.add_argument('-up', '--user-pull', action='store_true',
help='Pull personal repos')
parser.add_argument('-gc', '--gists-clone', action='store_true',
help='Clone personal gists')
parser.add_argument('-gp', '--gists-pull', action='store_true',
help='Pull personal gists.')
parser.add_argument('-oc', '--orgs-clone', action='store_true',
help='Clone organization repos.')
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.')
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',
help='Clone personal repos.',
)
parser.add_argument(
'-up',
'--user-pull',
action='store_true',
help='Pull personal repos',
)
parser.add_argument(
'-gc',
'--gists-clone',
action='store_true',
help='Clone personal gists',
)
parser.add_argument(
'-gp',
'--gists-pull',
action='store_true',
help='Pull personal gists.',
)
parser.add_argument(
'-oc',
'--orgs-clone',
action='store_true',
help='Clone organization repos.',
)
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.',
)
args = parser.parse_args()

# Environment variables
TOKEN = os.getenv('GITHUB_ARCHIVE_TOKEN')
ORG_LIST = os.getenv('GITHUB_ARCHIVE_ORGS', '')
ORGS = ORG_LIST.split(', ')
LOCATION = os.path.expanduser(
os.getenv('GITHUB_ARCHIVE_LOCATION', '~/github-archive'))
os.getenv('GITHUB_ARCHIVE_LOCATION', '~/github-archive')
)

# Reusable variables
USER = Github(TOKEN)
Expand All @@ -50,7 +80,8 @@ class Archive():

@classmethod
def clone_repos(cls, repo, path):
"""Clone repos that don't exist"""
"""Clone repos that don't exist
"""
if not os.path.exists(path):
try:
git = subprocess.check_output(
Expand All @@ -73,7 +104,8 @@ def clone_repos(cls, repo, path):

@classmethod
def pull_repos(cls, repo, path):
"""Pull changes for projects that are cloned"""
"""Pull changes for projects that are cloned
"""
try:
git = subprocess.check_output(
f'cd {path} && git pull --ff-only',
Expand All @@ -90,7 +122,8 @@ def pull_repos(cls, repo, path):

@classmethod
def clone_gists(cls, gist, path):
"""Clone gists"""
"""Clone gists
"""
if not os.path.exists(os.path.join(Archive.LOCATION, 'gists')):
os.makedirs(os.path.join(Archive.LOCATION, 'gists'))
if not os.path.exists(path):
Expand All @@ -114,7 +147,8 @@ def clone_gists(cls, gist, path):

@classmethod
def pull_gists(cls, gist, path):
"""Pull Gists"""
"""Pull Gists
"""
if not os.path.exists(os.path.join(Archive.LOCATION, 'gists')):
os.makedirs(os.path.join(Archive.LOCATION, 'gists'))
try:
Expand All @@ -133,15 +167,17 @@ def pull_gists(cls, gist, path):

@classmethod
def logs(cls, data):
"""Write output to a log"""
"""Write output to a log
"""
if not os.path.exists(Archive.LOG_PATH):
os.makedirs(Archive.LOG_PATH)
with open(Archive.LOG_FILE, 'a') as log:
log.write(f'\n{data}')


def main():
"""Run the based on configuration script"""
"""Run the based on configuration script
"""
if not os.path.exists(Archive.LOCATION):
os.makedirs(Archive.LOCATION)
if not Archive.TOKEN:
Expand Down
4 changes: 2 additions & 2 deletions 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.1',
version='2.1.2',
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 All @@ -31,7 +31,7 @@
},
entry_points={
'console_scripts': [
'github_archive=githubarchive.github_archive:main'
'github-archive=githubarchive.github_archive:main'
]
},
python_requires='>=3.6',
Expand Down

0 comments on commit eb35198

Please sign in to comment.