diff --git a/README.md b/README.md index 6983d9f..54ff1de 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Options: 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. + -ht, --https Use HTTPS URLs instead of SSH. ``` ### Automating SSH Passphrase Prompt (Recommended) diff --git a/github_archive/archive.py b/github_archive/archive.py index ae3bbae..cb8179b 100644 --- a/github_archive/archive.py +++ b/github_archive/archive.py @@ -37,6 +37,7 @@ def __init__( threads=DEFAULT_NUM_THREADS, token=None, location=DEFAULT_LOCATION, + use_https=False, ): # Parameter variables self.view = view @@ -51,6 +52,7 @@ def __init__( self.threads = threads self.token = token self.location = location + self.use_https = use_https # Internal variables self.github_instance = Github(self.token) if self.token else Github() self.authenticated_user = self.github_instance.get_user() if self.token else None @@ -270,9 +272,13 @@ def archive_repo(self, thread_limiter, repo, repo_path, operation): pass else: commands = { - CLONE_OPERATION: f'git clone {repo.ssh_url} {repo_path}', PULL_OPERATION: f'cd {repo_path} && git pull --rebase', } + + if self.use_https: + commands.update({CLONE_OPERATION: f'git clone {repo.html_url} {repo_path}'}) + else: + commands.update({CLONE_OPERATION: f'git clone {repo.ssh_url} {repo_path}'}) git_command = commands[operation] try: diff --git a/github_archive/cli.py b/github_archive/cli.py index 503a10b..bb5da36 100644 --- a/github_archive/cli.py +++ b/github_archive/cli.py @@ -110,6 +110,14 @@ def __init__(self): default=DEFAULT_LOCATION, help='The location where you want your GitHub Archive to be stored.', ) + parser.add_argument( + '-ht', + '--https', + action='store_true', + required=False, + default=False, + help='Use HTTPS URLs instead of SSH.', + ) parser.parse_args(namespace=self) def run(self): @@ -126,6 +134,7 @@ def run(self): threads=self.threads, token=self.token, location=self.location, + use_https=self.https, ) github_archive.run()