Skip to content

Commit

Permalink
chore: version bump to v4.0.0 (#34)
Browse files Browse the repository at this point in the history
* chore: version bump to v4.0.0

* fix: correct tests

* fix: correct tests
  • Loading branch information
Justintime50 authored Aug 25, 2021
1 parent 6251379 commit 1242801
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
pythonversion: ["3.6", "3.7", "3.8", "3.9"]
pythonversion: ["3.7", "3.8", "3.9"]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
Expand Down
20 changes: 10 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# CHANGELOG

## NEXT RELEASE
## v4.0.0 (TODO)

### Breaking Changes

* The `--user_clone` and `--user_pull` flags are now titled `--personal_clone` and `--personal_pull` as the new `--user_clone` and `--user_pull` flags are used for a list of specified users
* Removes the `GITHUB_ARCHIVE_BUFFER` environment variable in favor of the new `--threads` flag
* Reworks the entire app config to use CLI flags solely instead of a mix of CLI flags and env variables, see the README for new usage instructions or run `github-archive --help` (closes #30)
* Reworks the entire app config to use CLI flags solely instead of a mix of CLI flags and env variables, additionally, most flags have changed names and functionality. See the README for new usage instructions or run `github-archive --help` (closes #30)
* Repos or gists that fail to clone or pull will now be completely removed so that they can be retried from scratch on the next run of the tool. This was an especially important change for bad clones as the tool would previously leave an empty initialized git folder even if the clone failed which would not possess the actual git repo yet. In this state, you could not properly pull new changes because the content of the repo hadn't properly been cloned yet
* Bumps required Python version from 3.6 to 3.7

### Features

* Adds the ability to specify a list of users via `GITHUB_ARCHIVE_USERS` to clone and pull repos for via the `--users_clone` and `--users_pull` flags (closes #20)
* Added the `--threads` flag which can specify the number of concurrent threads to run at once (closes #22)
* Adds a new `--users` flag which can be used to clone or pull git assets for a list of comma separated users (closes #20)
* Adds a new `--threads` flag which can specify the number of concurrent threads to run at once, default is `10` (closes #22)
* Adds a new `--view` flag which allows you to "dry run" the application, seeing the entire list of repos and gists based on the input provided (closes #25)
* Adds a new `--stars` flag which you can pass a comma separated list of users to and GitHub Archive will retrieve all of their starred repos which you can then view, clone, or pull (closes #26)
* Adds a new `--forks` flag which will include forks for whatever lists and operations you provide (closes #17))
* Adds a new `--forks` flag which will include forks for whatever lists and operations you provide, default is `False` (closes #17))

### Fixes

* Removed verbose logging of skipped actions and "Already up to date" messages. Added additional logging related to API calls
* Adds proper validation of the `GITHUB_ARCHIVE_ORGS` variable on startup
* Various code refactor, bug fixes, and optimizations
* Bumped the default git operation timeout from 180 seconds to 300 seconds for larger repos (closes #22)
* Added proper validation and type checking of variables and environment on startup
* Various code refactors, bug fixes, and optimizations
* Bumped the default git operation timeout from `180 seconds` to `300 seconds` to assist with cloning or pulling larger repos (closes #22)
* Removes `mock` library in favor of builtin `unittest.mock` library

## v3.1.1 (2021-07-24)

Expand Down
82 changes: 34 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# GitHub Archive

A powerful script to concurrently clone your entire GitHub instance or save it as an archive.
A powerful tool to concurrently clone or pull user and org repos and gists to create a GitHub archive.

[![Build Status](https://github.com/Justintime50/github-archive/workflows/build/badge.svg)](https://github.com/Justintime50/github-archive/actions)
[![Coverage Status](https://coveralls.io/repos/github/Justintime50/github-archive/badge.svg?branch=main)](https://coveralls.io/github/Justintime50/github-archive?branch=main)
Expand All @@ -13,25 +13,11 @@ A powerful script to concurrently clone your entire GitHub instance or save it a

</div>

GitHub Archive will clone any repo and gist that doesn't exist locally and pull those that do from the main branch of each repo and latest revision of each gist that you have access to - including organizations (if configured).

## What Can it Do?

* Clone/pull personal repos (public and private)
* Clone/pull organization repos (public and private)
* Clone/pull personal gists (public and private)
* Iterate over infinite number of repos and gists concurrently
* Great use case: Run on a schedule to automate pulling changes or keep a local backup of all your repos
GitHub Archive is a powerful tool to concurrently clone or pull repositories or gists from GitHub with incredible flexibility. It's the perfect tool for spinning up a new dev environment, keeping a local copy of your GitHub instance, or quickly pulling in projects from your favorite users and organizations.

### Configurable Settings

The power of GitHub Archive comes in its configuration. Maybe you only want to clone/pull your personal public repos or maybe you want to go all out and include private repos from you and all organizations you belong to including your gists. Iterate over all your repos concurrently and sit back while GitHub Archive does the work.

* Personal repos cloning/pulling
* Organization repos cloning/pulling
* Gists cloning/pulling
* List of organizations to include
* A host of environment variables to tweak GitHub Archive even further to meet your needs
The power of GitHub Archive comes in its configuration. Maybe you only want to clone or pull your personal public repos or maybe you want to go all out and include private repos from you and all organizations you belong to along with your gists.

## Install

Expand All @@ -46,6 +32,35 @@ make install
make help
```

## Usage

```
Usage:
github-archive --users justintime50 --clone
Options:
-h, --help show this help message and exit
-v, --view Pass this flag to view git assets (dry run).
-c, --clone Pass this flag to clone git assets.
-p, --pull Pass this flag to pull git assets.
-f, --forks Pass this flag to include forked git assets.
-u USERS, --users USERS
Pass a comma separated list of users to get repos for.
-o ORGS, --orgs ORGS Pass a comma separated list of orgs to get repos for.
-g GISTS, --gists GISTS
Pass a comma separated list of users to get gists for.
-s STARS, --stars STARS
Pass a comma separated list of users to get starred repos for.
-to TIMEOUT, --timeout TIMEOUT
The number of seconds before a git operation times out.
-th THREADS, --threads THREADS
The number of concurrent threads to run.
-t TOKEN, --token TOKEN
Provide your GitHub token to authenticate with the GitHub API and gain access to private repos and gists.
-l LOCATION, --location LOCATION
The location where you want your GitHub Archive to be stored.
```

### Automating SSH Passphrase Prompt (Recommended)

To allow the script to run continuosly without requiring your SSH passphrase, you'll need to add your passphrase to the SSH agent. **NOTE:** Your SSH passphrase will be unloaded upon logout.
Expand All @@ -55,38 +70,13 @@ To allow the script to run continuosly without requiring your SSH passphrase, yo
ssh-add
```

## Usage
### Notes

**SSH Key:** You must have an SSH key generated on your local machine and added to your GitHub account as this tool uses the `ssh_url` to clone/pull.

**Merge Conflicts:** Be aware that using GitHub Archive could lead to merge conflicts if you do not commit or stash your changes if using these repos as active development repos instead of simply an archive or one-time clone.

```
Basic Usage:
GITHUB_TOKEN=123... github-archive --user-clone --user-pull
Advanced Usage:
GITHUB_TOKEN=123... GITHUB_ARCHIVE_ORGS="org1, org2" GITHUB_ARCHIVE_LOCATION="~/custom_location" \
github-archive -uc -up -gc -gp -oc -op
Options:
-h, --help show this help message and exit
-uc, --user_clone Clone personal repos.
-up, --user_pull Pull personal repos
-gc, --gists_clone Clone personal gists
-gp, --gists_pull Pull personal gists.
-oc, --orgs_clone Clone organization repos.
-op, --orgs_pull Pull organization repos.
Environment Variables:
GITHUB_TOKEN expects a string of your GitHub Token
GITHUB_ARCHIVE_ORGS expects a string of comma separated orgs. eg: "org1, org2"
GITHUB_ARCHIVE_LOCATION expects a string of an explicit location on your machine (eg: "~/custom_location"). Default: ~/github-archive
GITHUB_ARCHIVE_BUFFER expects a float for the buffer inbetween requests. Default: 0.1
GITHUB_ARCHIVE_TIMEOUT expects an int for the number of seconds before a git operation times out. Default: 180
GITHUB_ARCHIVE_LOG_MAX_BYTES expects an int of the max bytes that a log will grow to. Once the log exceeds this number, it will rollover to another log. Default: 200000
GITHUB_ARCHIVE_LOG_BACKUP_COUNT expects an int of the number of logs to rollover once a single log exceeds the max bytes size. Default: 5
```
**Access**: GitHub Archive can only clone or pull repos that the authenticated user has access to. This means that private repos from another user or org that you don't have access to will not be able to be cloned or pulled.

## Development

Expand All @@ -103,7 +93,3 @@ make coverage
# Run the tool locally
venv/bin/python github_archive/cli.py --help
```

## Legacy Script

This tool was initially built in Bash and later re-written in Python. If you'd like to use or view the legacy script, check out the separate [Legacy README](legacy/README.md).
107 changes: 0 additions & 107 deletions README_v4.md

This file was deleted.

9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
DEV_REQUIREMENTS = [
'coveralls == 3.*',
'flake8',
'mock == 4.*',
'pytest == 6.*',
'pytest-cov == 2.*',
]

setuptools.setup(
name='github-archive',
version='3.1.1',
description='A powerful tool to concurrently clone or pull user and org repos and gists to create a GitHub archive.', # noqa
version='4.0.0',
description=(
'A powerful tool to concurrently clone or pull user and org repos and gists to create a GitHub archive.'
),
long_description=long_description,
long_description_content_type="text/markdown",
url='http://github.com/justintime50/github-archive',
Expand All @@ -39,5 +40,5 @@
'github-archive=github_archive.cli:main',
]
},
python_requires='>=3.6',
python_requires='>=3.7',
)
5 changes: 3 additions & 2 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mock
from unittest.mock import MagicMock

import pytest


Expand All @@ -7,7 +8,7 @@ def mock_git_asset():
"""This can be used for repos and/or gists, it contains shared data
for either git asset for easier testing.
"""
mock_git_asset = mock.MagicMock()
mock_git_asset = MagicMock()
mock_git_asset.id = '123'
mock_git_asset.name = 'mock-asset-name'
mock_git_asset.owner.name = 'Mock User Name'
Expand Down
Loading

0 comments on commit 1242801

Please sign in to comment.