FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support archivization using bare git clones · theapi/python-github-backup@8d61538 · GitHub

Commit 8d61538

Browse files
committed
Support archivization using bare git clones
1 parent 4d37ad2 commit 8d61538

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎README.rst‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ CLI Usage is as follows::
2929
[-o OUTPUT_DIRECTORY] [-i] [--starred] [--watched]
3030
[--all] [--issues] [--issue-comments] [--issue-events]
3131
[--pulls] [--pull-comments] [--pull-commits] [--labels]
32-
[--hooks] [--milestones] [--repositories] [--wikis]
33-
[--skip-existing] [-L [LANGUAGES [LANGUAGES ...]]]
34-
[-N NAME_REGEX] [-H GITHUB_HOST] [-O] [-R REPOSITORY]
35-
[-P] [-F] [--prefer-ssh] [-v]
32+
[--hooks] [--milestones] [--repositories] [--bare]
33+
[--wikis] [--skip-existing]
34+
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
35+
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
36+
[--prefer-ssh] [-v]
3637
USER
3738

3839
Backup a github account
@@ -66,6 +67,7 @@ CLI Usage is as follows::
6667
authenticated)
6768
--milestones include milestones in backup
6869
--repositories include repository clone in backup
70+
--bare clone bare repositories
6971
--wikis include wiki clone in backup
7072
--skip-existing skip project if a backup directory exists
7173
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]

‎bin/github-backup‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ def parse_args():
204204
action='store_true',
205205
dest='include_repository',
206206
help='include repository clone in backup')
207+
parser.add_argument('--bare',
208+
action='store_true',
209+
dest='bare_clone',
210+
help='clone bare repositories')
207211
parser.add_argument('--wikis',
208212
action='store_true',
209213
dest='include_wiki',
@@ -508,14 +512,16 @@ def backup_repositories(args, output_directory, repositories):
508512
fetch_repository(repository['name'],
509513
repo_url,
510514
repo_dir,
511-
skip_existing=args.skip_existing)
515+
skip_existing=args.skip_existing,
516+
bare_clone=args.bare_clone)
512517

513518
download_wiki = (args.include_wiki or args.include_everything)
514519
if repository['has_wiki'] and download_wiki:
515520
fetch_repository(repository['name'],
516521
repo_url.replace('.git', '.wiki.git'),
517522
os.path.join(repo_cwd, 'wiki'),
518-
skip_existing=args.skip_existing)
523+
skip_existing=args.skip_existing,
524+
bare_clone=args.bare_clone)
519525

520526
if args.include_issues or args.include_everything:
521527
backup_issues(args, repo_cwd, repository, repos_template)
@@ -695,7 +701,7 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
695701
log_info("Unable to read hooks, skipping")
696702

697703

698-
def fetch_repository(name, remote_url, local_dir, skip_existing=False):
704+
def fetch_repository(name, remote_url, local_dir, skip_existing=False, bare_clone=False):
699705
clone_exists = os.path.exists(os.path.join(local_dir, '.git'))
700706

701707
if clone_exists and skip_existing:
@@ -723,7 +729,10 @@ def fetch_repository(name, remote_url, local_dir, skip_existing=False):
723729
log_info('Cloning {0} repository from {1} to {2}'.format(name,
724730
masked_remote_url,
725731
local_dir))
726-
git_command = ['git', 'clone', remote_url, local_dir]
732+
if bare_clone:
733+
git_command = ['git', 'clone', '--bare', remote_url, local_dir]
734+
else:
735+
git_command = ['git', 'clone', remote_url, local_dir]
727736
logging_subprocess(git_command, None)
728737

729738

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL