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

Add --hooks to also include web hooks into the backup · srault95/python-github-backup@fe162ee · GitHub

Commit fe162ee

Browse files
committed
Add --hooks to also include web hooks into the backup
1 parent 53a9a22 commit fe162ee

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎README.rst‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CLI Usage is as follows::
2424
[-o OUTPUT_DIRECTORY] [--starred] [--watched] [--all]
2525
[--issues] [--issue-comments] [--issue-events] [--pulls]
2626
[--pull-comments] [--pull-commits] [--repositories]
27-
[--wikis] [--skip-existing]
27+
[--wikis] [--labels] [--hooks] [--skip-existing]
2828
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
2929
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
3030
[--prefer-ssh] [-v]
@@ -57,6 +57,8 @@ CLI Usage is as follows::
5757
--pull-commits include pull request commits in backup
5858
--repositories include repository clone in backup
5959
--wikis include wiki clone in backup
60+
--labels include labels in backup
61+
--hooks include web hooks in backup (works only when authenticated)
6062
--skip-existing skip project if a backup directory exists
6163
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]
6264
only allow these languages
@@ -71,6 +73,6 @@ CLI Usage is as follows::
7173
-F, --fork include forked repositories
7274
--prefer-ssh Clone repositories using SSH instead of HTTPS
7375
-v, --version show program's version number and exit
74-
76+
7577

7678
The package can be used to backup an *entire* organization or repository, including issues and wikis in the most appropriate format (clones for wikis, json files for issues).

‎bin/github-backup‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ def parse_args():
159159
action='store_true',
160160
dest='include_labels',
161161
help='include labels in backup')
162+
parser.add_argument('--hooks',
163+
action='store_true',
164+
dest='include_hooks',
165+
help='include hooks in backup (works only when authenticated)')
162166
parser.add_argument('--milestones',
163167
action='store_true',
164168
dest='include_milestones',
@@ -450,6 +454,9 @@ def backup_repositories(args, output_directory, repositories):
450454
if args.include_labels or args.include_everything:
451455
backup_labels(args, repo_cwd, repository, repos_template)
452456

457+
if args.include_hooks or args.include_everything:
458+
backup_hooks(args, repo_cwd, repository, repos_template)
459+
453460

454461
def backup_issues(args, repo_cwd, repository, repos_template):
455462
has_issues_dir = os.path.isdir('{0}/issues/.git'.format(repo_cwd))
@@ -575,6 +582,22 @@ def backup_labels(args, repo_cwd, repository, repos_template):
575582
label_cwd)
576583

577584

585+
def backup_hooks(args, repo_cwd, repository, repos_template):
586+
auth = get_auth(args)
587+
if not auth:
588+
log_info("Skipping hooks since no authentication provided")
589+
return
590+
hook_cwd = os.path.join(repo_cwd, 'hooks')
591+
output_file = '{0}/hooks.json'.format(hook_cwd)
592+
template = '{0}/{1}/hooks'.format(repos_template,
593+
repository['full_name'])
594+
_backup_data(args,
595+
'hooks',
596+
template,
597+
output_file,
598+
hook_cwd)
599+
600+
578601
def fetch_repository(name, remote_url, local_dir, skip_existing=False):
579602
clone_exists = os.path.exists(os.path.join(local_dir, '.git'))
580603

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL