github-backup 0.62.1__py3-none-any.whl → 0.63.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
github_backup/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.62.1"
1
+ __version__ = "0.63.0"
@@ -2657,10 +2657,20 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
2657
2657
  def pull_is_due_for_repository_checkpoint(pull):
2658
2658
  return not repository_since or pull["updated_at"] > repository_since
2659
2659
 
2660
- if not args.include_pull_details:
2661
- pull_states = ["open", "closed"]
2662
- for pull_state in pull_states:
2663
- query_args["state"] = pull_state
2660
+ try:
2661
+ if not args.include_pull_details:
2662
+ pull_states = ["open", "closed"]
2663
+ for pull_state in pull_states:
2664
+ query_args["state"] = pull_state
2665
+ for pull in retrieve_data(
2666
+ args, _pulls_template, query_args=query_args, lazy=True
2667
+ ):
2668
+ track_newest_pull_update(pull)
2669
+ if pulls_since and pull["updated_at"] <= pulls_since:
2670
+ break
2671
+ if not pulls_since or pull["updated_at"] > pulls_since:
2672
+ pulls[pull["number"]] = pull
2673
+ else:
2664
2674
  for pull in retrieve_data(
2665
2675
  args, _pulls_template, query_args=query_args, lazy=True
2666
2676
  ):
@@ -2669,22 +2679,29 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
2669
2679
  break
2670
2680
  if not pulls_since or pull["updated_at"] > pulls_since:
2671
2681
  pulls[pull["number"]] = pull
2672
- else:
2673
- for pull in retrieve_data(
2674
- args, _pulls_template, query_args=query_args, lazy=True
2675
- ):
2676
- track_newest_pull_update(pull)
2677
- if pulls_since and pull["updated_at"] <= pulls_since:
2678
- break
2679
- if not pulls_since or pull["updated_at"] > pulls_since:
2680
- if pull_is_due_for_repository_checkpoint(pull):
2681
- pulls[pull["number"]] = retrieve_data(
2682
- args,
2683
- _pulls_template + "/{}".format(pull["number"]),
2684
- paginated=False,
2685
- )[0]
2686
- else:
2687
- pulls[pull["number"]] = pull
2682
+ except HTTPError as e:
2683
+ # Repositories with pull requests disabled return HTTP 404 for the
2684
+ # listing endpoint; treat that as "no pull requests" rather than a
2685
+ # fatal error. retrieve_data is lazy here, so the 404 surfaces during
2686
+ # iteration. Only the listing call is guarded — a 404 on an individual
2687
+ # pull's detail fetch below is a different condition and must propagate.
2688
+ if e.code == 404:
2689
+ logger.info("Pull requests are disabled for this repository, skipping")
2690
+ return
2691
+ raise
2692
+
2693
+ if args.include_pull_details:
2694
+ # Replace the summary payload with the full pull detail. Done outside
2695
+ # the disabled-feature guard above so a 404 on a single pull (e.g. one
2696
+ # deleted between listing and fetch) is not mistaken for the whole
2697
+ # feature being disabled, which would discard every collected pull.
2698
+ for number in list(pulls.keys()):
2699
+ if pull_is_due_for_repository_checkpoint(pulls[number]):
2700
+ pulls[number] = retrieve_data(
2701
+ args,
2702
+ _pulls_template + "/{}".format(number),
2703
+ paginated=False,
2704
+ )[0]
2688
2705
 
2689
2706
  logger.info("Saving {0} pull requests to disk".format(len(list(pulls.keys()))))
2690
2707
  # Comments from pulls API are only _review_ comments
@@ -2813,8 +2830,8 @@ def backup_security_advisories(args, repo_cwd, repository, repos_template):
2813
2830
 
2814
2831
  try:
2815
2832
  _advisories = retrieve_data(args, template)
2816
- except Exception as e:
2817
- if "404" in str(e):
2833
+ except HTTPError as e:
2834
+ if e.code == 404:
2818
2835
  logger.info("Security advisories are not available for this repository, skipping")
2819
2836
  return
2820
2837
  raise
@@ -2861,8 +2878,8 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
2861
2878
  template = "{0}/{1}/hooks".format(repos_template, repository["full_name"])
2862
2879
  try:
2863
2880
  _backup_data(args, "hooks", template, output_file, hook_cwd)
2864
- except Exception as e:
2865
- if "404" in str(e):
2881
+ except HTTPError as e:
2882
+ if e.code == 404:
2866
2883
  logger.info("Unable to read hooks, skipping")
2867
2884
  else:
2868
2885
  raise e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github-backup
3
- Version: 0.62.1
3
+ Version: 0.63.0
4
4
  Summary: backup a github user or organization
5
5
  Home-page: http://github.com/josegonzalez/python-github-backup
6
6
  Author: Jose Diaz-Gonzalez
@@ -0,0 +1,12 @@
1
+ github_backup/__init__.py,sha256=Q5rNe5SDDfUHvL3frAP-ZMPMx4ucG3RXhgWSZiluxeM,23
2
+ github_backup/__main__.py,sha256=3yorCiC63maaxbjdtaeAs-G-yAAxKSO3mprhGfa1Fho,271
3
+ github_backup/cli.py,sha256=gPYU0CviuHB19y8RHhcD0p8xHS3UcJbBIK6HVfWazTc,2902
4
+ github_backup/github_backup.py,sha256=z4YvI61NedaDnE256GB-3pfbaJ5rwpZx4KItgjCaQnk,115713
5
+ github_backup/graphql_queries.py,sha256=QBIXcGzGunilMpHfL32cTO_AAzxuQD27QII1V9K_Yw4,4883
6
+ github_backup-0.63.0.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
7
+ github_backup-0.63.0.dist-info/METADATA,sha256=a6sgqCD4lUo95EkTCN04g4ufzT-RoyfXdD67GlGpJkk,32426
8
+ github_backup-0.63.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
9
+ github_backup-0.63.0.dist-info/entry_points.txt,sha256=cLPKK7MqC77QVb6HnT2mnyL_f-ciavJG_Y9vVHlCF68,57
10
+ github_backup-0.63.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
11
+ github_backup-0.63.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
+ github_backup-0.63.0.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- github_backup/__init__.py,sha256=jT5y_EapSG_XUwBZcJ6_jD1uAUUE11ZbHJwMsKfUuQM,23
2
- github_backup/__main__.py,sha256=3yorCiC63maaxbjdtaeAs-G-yAAxKSO3mprhGfa1Fho,271
3
- github_backup/cli.py,sha256=gPYU0CviuHB19y8RHhcD0p8xHS3UcJbBIK6HVfWazTc,2902
4
- github_backup/github_backup.py,sha256=KIYfHJxxQn82C2K8RaAl4wmOSClxQWoBW8kFyFZ8pUw,114736
5
- github_backup/graphql_queries.py,sha256=QBIXcGzGunilMpHfL32cTO_AAzxuQD27QII1V9K_Yw4,4883
6
- github_backup-0.62.1.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
7
- github_backup-0.62.1.dist-info/METADATA,sha256=5WD559hLSwkWmjiAtOFqZnyv-ycErCS7z1LUSAkdqRs,32426
8
- github_backup-0.62.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
9
- github_backup-0.62.1.dist-info/entry_points.txt,sha256=cLPKK7MqC77QVb6HnT2mnyL_f-ciavJG_Y9vVHlCF68,57
10
- github_backup-0.62.1.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
11
- github_backup-0.62.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
- github_backup-0.62.1.dist-info/RECORD,,