github-backup 0.65.1__py3-none-any.whl → 0.66.1__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.65.1"
1
+ __version__ = "0.66.1"
@@ -1838,6 +1838,11 @@ def retrieve_repositories(args, authenticated_user):
1838
1838
  if args.user == authenticated_user["login"]:
1839
1839
  # we must use the /user/repos API to be able to access private repos
1840
1840
  template = "https://{0}/user/repos".format(get_github_api_host(args))
1841
+ elif args.as_app and not args.organization:
1842
+ # /users/{user}/repos is public-only; the installation sees private repos too
1843
+ template = "https://{0}/installation/repositories".format(
1844
+ get_github_api_host(args)
1845
+ )
1841
1846
  else:
1842
1847
  if args.private and not args.organization:
1843
1848
  logger.warning(
@@ -1868,6 +1873,10 @@ def retrieve_repositories(args, authenticated_user):
1868
1873
  logger.warning(f"Legal notice: {e.legal_url}")
1869
1874
  return []
1870
1875
 
1876
+ if template.endswith("/installation/repositories"):
1877
+ # Each page is {"total_count": ..., "repositories": [...]}
1878
+ repos = [repo for page in repos for repo in page["repositories"]]
1879
+
1871
1880
  return retrieve_additional_repositories(args, authenticated_user, repos)
1872
1881
 
1873
1882
 
@@ -3146,6 +3155,15 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
3146
3155
  if not auth:
3147
3156
  logger.info("Skipping hooks since no authentication provided")
3148
3157
  return
3158
+ # Reading hooks needs admin access, and GitHub returns 404 without it.
3159
+ # Skip the request when the repository listing says we aren't an admin.
3160
+ if repository.get("permissions", {}).get("admin") is False:
3161
+ logger.info(
3162
+ "Skipping hooks for {0} since admin access is required".format(
3163
+ repository["full_name"]
3164
+ )
3165
+ )
3166
+ return
3149
3167
  hook_cwd = os.path.join(repo_cwd, "hooks")
3150
3168
  output_file = "{0}/hooks.json".format(hook_cwd)
3151
3169
  template = "{0}/{1}/hooks".format(repos_template, repository["full_name"])
@@ -3153,7 +3171,12 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
3153
3171
  _backup_data(args, "hooks", template, output_file, hook_cwd)
3154
3172
  except HTTPError as e:
3155
3173
  if e.code == 404:
3156
- logger.info("Unable to read hooks, skipping")
3174
+ logger.info(
3175
+ "Unable to read hooks for {0}, skipping (requires admin access, "
3176
+ "or Webhooks read permission for fine-grained tokens)".format(
3177
+ repository["full_name"]
3178
+ )
3179
+ )
3157
3180
  else:
3158
3181
  raise e
3159
3182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github-backup
3
- Version: 0.65.1
3
+ Version: 0.66.1
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
@@ -229,6 +229,8 @@ GitHub Apps
229
229
 
230
230
  GitHub Apps are ideal for organization backups in CI/CD. Tokens are scoped to specific repositories and expire after 1 hour.
231
231
 
232
+ For a user account (no ``--organization``), ``--as-app`` lists the repositories the installation can access, so private repositories are included.
233
+
232
234
  **One-time setup:**
233
235
 
234
236
  1. Create a GitHub App at *Settings -> Developer Settings -> GitHub Apps -> New GitHub App*
@@ -435,11 +437,9 @@ If the incremental argument is used, per-resource checkpoints are only advanced
435
437
 
436
438
  It's therefore recommended to only use the incremental argument if the output/result is being actively monitored, or complimented with periodic full non-incremental runs, to avoid unexpected missing data in a regular backup runs.
437
439
 
438
- **Starred public repo hooks blocking**
439
-
440
- Since the ``--all`` argument includes ``--hooks``, if you use ``--all`` and ``--all-starred`` together to clone a users starred public repositories, the backup will likely error and block the backup continuing.
440
+ **Hooks need admin access**
441
441
 
442
- This is due to needing the correct permission for ``--hooks`` on public repos.
442
+ Reading a repository's hooks requires admin access to it, and fine-grained tokens also need the Webhooks read permission. Since the ``--all`` argument includes ``--hooks``, repositories you don't administer, such as starred repositories with ``--all-starred``, are skipped for hooks and the rest of the backup continues.
443
443
 
444
444
 
445
445
  "bare" is actually "mirror"
@@ -0,0 +1,12 @@
1
+ github_backup/__init__.py,sha256=Y_9EKLxx08OQDNPkUFPkOvW0swweoBoNGuSmF8BmY9s,23
2
+ github_backup/__main__.py,sha256=3yorCiC63maaxbjdtaeAs-G-yAAxKSO3mprhGfa1Fho,271
3
+ github_backup/cli.py,sha256=JTiXPOvB8id8LopREOEd1W_FLvuf9SOZU5buMRPFd9U,2922
4
+ github_backup/github_backup.py,sha256=m-pN6QDINtl4-ElNBjkuWOhydwgLITRxkRfZeAIQmvE,127713
5
+ github_backup/graphql_queries.py,sha256=XcAQyp9nF7Ip9UzxsrXMkl2pO-W7SK8hhO2oE9HVcmA,6658
6
+ github_backup-0.66.1.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
7
+ github_backup-0.66.1.dist-info/METADATA,sha256=bTU1Yw07sSyiygsiFas4iI4ppAmMI3EKMGzq3ZSD2OU,36215
8
+ github_backup-0.66.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ github_backup-0.66.1.dist-info/entry_points.txt,sha256=cLPKK7MqC77QVb6HnT2mnyL_f-ciavJG_Y9vVHlCF68,57
10
+ github_backup-0.66.1.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
11
+ github_backup-0.66.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
+ github_backup-0.66.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (83.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- github_backup/__init__.py,sha256=rGqIS-DtyspfkizhuNt82yLT-d6kScjVTMqpbJpBReo,23
2
- github_backup/__main__.py,sha256=3yorCiC63maaxbjdtaeAs-G-yAAxKSO3mprhGfa1Fho,271
3
- github_backup/cli.py,sha256=JTiXPOvB8id8LopREOEd1W_FLvuf9SOZU5buMRPFd9U,2922
4
- github_backup/github_backup.py,sha256=XZjLwdQ8OftyImqmW2zMgqn8sEfuhAfAvmfNhdxF23o,126671
5
- github_backup/graphql_queries.py,sha256=XcAQyp9nF7Ip9UzxsrXMkl2pO-W7SK8hhO2oE9HVcmA,6658
6
- github_backup-0.65.1.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
7
- github_backup-0.65.1.dist-info/METADATA,sha256=r2IogtJ7P6ZA7ITMRM6h3yXhCFy9y2OrINvzzkz-Js8,36048
8
- github_backup-0.65.1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
9
- github_backup-0.65.1.dist-info/entry_points.txt,sha256=cLPKK7MqC77QVb6HnT2mnyL_f-ciavJG_Y9vVHlCF68,57
10
- github_backup-0.65.1.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
11
- github_backup-0.65.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
- github_backup-0.65.1.dist-info/RECORD,,