githubtakeout 0.1.12__tar.gz → 0.1.13__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: githubtakeout
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: Backup and archive Git Repos and Gists from GitHub
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -86,7 +86,7 @@ the `--token` argument.
86
86
  ## CLI Options:
87
87
 
88
88
  ```
89
- usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
89
+ usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
90
90
 
91
91
  positional arguments:
92
92
  username github username
@@ -94,6 +94,7 @@ positional arguments:
94
94
  options:
95
95
  -h, --help show this help message and exit
96
96
  --dir DIR output directory (default: .)
97
+ --pattern PATTERN regex matching repo names (default: .*)
97
98
  --format {tar,zip,none} archive format (default: zip)
98
99
  --gists include gists
99
100
  --history include commit history and branches (.git directory)
@@ -61,7 +61,7 @@ the `--token` argument.
61
61
  ## CLI Options:
62
62
 
63
63
  ```
64
- usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
64
+ usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
65
65
 
66
66
  positional arguments:
67
67
  username github username
@@ -69,6 +69,7 @@ positional arguments:
69
69
  options:
70
70
  -h, --help show this help message and exit
71
71
  --dir DIR output directory (default: .)
72
+ --pattern PATTERN regex matching repo names (default: .*)
72
73
  --format {tar,zip,none} archive format (default: zip)
73
74
  --gists include gists
74
75
  --history include commit history and branches (.git directory)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "githubtakeout"
7
- version = "0.1.12"
7
+ version = "0.1.13"
8
8
  description = "Backup and archive Git Repos and Gists from GitHub"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: githubtakeout
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: Backup and archive Git Repos and Gists from GitHub
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -86,7 +86,7 @@ the `--token` argument.
86
86
  ## CLI Options:
87
87
 
88
88
  ```
89
- usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
89
+ usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
90
90
 
91
91
  positional arguments:
92
92
  username github username
@@ -94,6 +94,7 @@ positional arguments:
94
94
  options:
95
95
  -h, --help show this help message and exit
96
96
  --dir DIR output directory (default: .)
97
+ --pattern PATTERN regex matching repo names (default: .*)
97
98
  --format {tar,zip,none} archive format (default: zip)
98
99
  --gists include gists
99
100
  --history include commit history and branches (.git directory)
@@ -8,6 +8,7 @@ import getpass
8
8
  import logging
9
9
  import math
10
10
  import os
11
+ import re
11
12
  import shutil
12
13
  import stat
13
14
  import sys
@@ -194,6 +195,7 @@ def get_token(prompt_for_token):
194
195
  def run(
195
196
  username,
196
197
  base_dir,
198
+ pattern,
197
199
  archive_format,
198
200
  include_gists,
199
201
  include_history,
@@ -203,28 +205,30 @@ def run(
203
205
  working_dir = os.path.join(base_dir, "backups")
204
206
  token = get_token(prompt_for_token)
205
207
  repos, gists = get_repos(username, token, include_gists)
206
- num_repos = repos.totalCount
208
+ num_repos = len([repo for repo in repos if re.match(pattern, repo.name)])
207
209
  if not list_only:
208
210
  logger.info(f"creating archives in: {working_dir}\n")
209
211
  logger.info(f"found {num_repos} repos for user '{username}'\n")
210
212
  for repo in repos:
211
- local_repo_dir = os.path.join(working_dir, repo.name)
212
- url = add_creds(repo.clone_url, username, token)
213
- if list_only:
214
- logger.info(url)
215
- else:
216
- clone_and_archive_repo(url, local_repo_dir, archive_format, include_history)
213
+ if re.match(pattern, repo.name):
214
+ local_repo_dir = os.path.join(working_dir, repo.name)
215
+ url = add_creds(repo.clone_url, username, token)
216
+ if list_only:
217
+ logger.info(url)
218
+ else:
219
+ clone_and_archive_repo(url, local_repo_dir, archive_format, include_history)
217
220
  if gists is not None:
218
- num_gists = gists.totalCount
221
+ num_gists = len([gist for gist in gists if re.match(pattern, gist.id)])
219
222
  logger.info("")
220
223
  logger.info(f"found {num_gists} gists for user '{username}'\n")
221
224
  for gist in gists:
222
- local_repo_dir = os.path.join(working_dir, gist.id)
223
- url = add_creds(gist.git_pull_url, username, token)
224
- if list_only:
225
- logger.info(url)
226
- else:
227
- clone_and_archive_repo(url, local_repo_dir, archive_format, include_history, is_gist=True)
225
+ if re.match(pattern, gist.id):
226
+ local_repo_dir = os.path.join(working_dir, gist.id)
227
+ url = add_creds(gist.git_pull_url, username, token)
228
+ if list_only:
229
+ logger.info(url)
230
+ else:
231
+ clone_and_archive_repo(url, local_repo_dir, archive_format, include_history, is_gist=True)
228
232
 
229
233
 
230
234
  def main():
@@ -241,6 +245,11 @@ def main():
241
245
  default=os.getcwd(),
242
246
  help="output directory (default: .)",
243
247
  )
248
+ parser.add_argument(
249
+ "--pattern",
250
+ default=".*",
251
+ help="regex matching repo names (default: .*)",
252
+ )
244
253
  parser.add_argument(
245
254
  "--format",
246
255
  choices=ARCHIVE_FORMATS,
@@ -261,6 +270,7 @@ def main():
261
270
  run(
262
271
  username=args.username,
263
272
  base_dir=args.dir,
273
+ pattern=args.pattern,
264
274
  archive_format=args.format,
265
275
  include_gists=args.gists,
266
276
  include_history=args.history,
File without changes
File without changes