batchfetch 1.1.8__tar.gz → 1.2.0__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.
Files changed (21) hide show
  1. {batchfetch-1.1.8/batchfetch.egg-info → batchfetch-1.2.0}/PKG-INFO +3 -7
  2. {batchfetch-1.1.8 → batchfetch-1.2.0}/README.md +2 -2
  3. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch/batchfetch_base.py +8 -12
  4. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch/batchfetch_git.py +41 -35
  5. {batchfetch-1.1.8 → batchfetch-1.2.0/batchfetch.egg-info}/PKG-INFO +3 -7
  6. {batchfetch-1.1.8 → batchfetch-1.2.0}/setup.py +1 -1
  7. {batchfetch-1.1.8 → batchfetch-1.2.0}/.gitignore +0 -0
  8. {batchfetch-1.1.8 → batchfetch-1.2.0}/LICENSE +0 -0
  9. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch/__init__.py +0 -0
  10. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch/batchfetch_cli.py +0 -0
  11. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch/helpers.py +0 -0
  12. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch.egg-info/SOURCES.txt +0 -0
  13. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch.egg-info/dependency_links.txt +0 -0
  14. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch.egg-info/entry_points.txt +0 -0
  15. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch.egg-info/requires.txt +1 -1
  16. {batchfetch-1.1.8 → batchfetch-1.2.0}/batchfetch.egg-info/top_level.txt +0 -0
  17. {batchfetch-1.1.8 → batchfetch-1.2.0}/run_tests.sh +0 -0
  18. {batchfetch-1.1.8 → batchfetch-1.2.0}/setup.cfg +0 -0
  19. {batchfetch-1.1.8 → batchfetch-1.2.0}/tests/data/test-md5sum.txt +0 -0
  20. {batchfetch-1.1.8 → batchfetch-1.2.0}/tests/data/test-run_simple.sh +0 -0
  21. {batchfetch-1.1.8 → batchfetch-1.2.0}/tests/test_helpers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batchfetch
3
- Version: 1.1.8
3
+ Version: 1.2.0
4
4
  Summary: Efficiently clone and pull multiple Git repositories.
5
5
  Home-page: https://github.com/jamescherti/batchfetch
6
6
  Author: James Cherti
@@ -17,10 +17,6 @@ Classifier: Topic :: Utilities
17
17
  Requires-Python: >=3.6, <4
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: colorama
21
- Requires-Dist: schema
22
- Requires-Dist: setproctitle
23
- Requires-Dist: PyYAML
24
20
 
25
21
  # Batchfetch - Efficiently clone or pull multiple Git repositories in parallel
26
22
 
@@ -61,12 +57,12 @@ tasks:
61
57
  # Clone the tag 1.5 of the consult repository to the './consult'
62
58
  # directory
63
59
  - git: https://github.com/minad/consult
64
- reference: "1.5"
60
+ revision: "1.5"
65
61
 
66
62
  # Clone the s.el repository to the './another-name.el' directory
67
63
  - git: https://github.com/magnars/s.el
68
64
  path: another-name.el
69
- reference: dda84d38fffdaf0c9b12837b504b402af910d01d
65
+ revision: dda84d38fffdaf0c9b12837b504b402af910d01d
70
66
 
71
67
  # Delete './impatient-mode'
72
68
  - git: https://github.com/skeeto/impatient-mode
@@ -37,12 +37,12 @@ tasks:
37
37
  # Clone the tag 1.5 of the consult repository to the './consult'
38
38
  # directory
39
39
  - git: https://github.com/minad/consult
40
- reference: "1.5"
40
+ revision: "1.5"
41
41
 
42
42
  # Clone the s.el repository to the './another-name.el' directory
43
43
  - git: https://github.com/magnars/s.el
44
44
  path: another-name.el
45
- reference: dda84d38fffdaf0c9b12837b504b402af910d01d
45
+ revision: dda84d38fffdaf0c9b12837b504b402af910d01d
46
46
 
47
47
  # Delete './impatient-mode'
48
48
  - git: https://github.com/skeeto/impatient-mode
@@ -145,24 +145,19 @@ class TaskBatchFetch(TaskBase):
145
145
 
146
146
  def _run_pre_exec(self, cwd: os.PathLike = Path(".")):
147
147
  self._initialize_data()
148
- for pre_exec in self["exec_before"]:
149
- if not pre_exec:
150
- continue
148
+ cmd = self["exec_before"]
149
+ if self["delete"] or not cmd:
150
+ return
151
151
 
152
- self._run(pre_exec, cwd=str(cwd), env=self.env,
153
- spaces=self.indent)
152
+ self._run(cmd, cwd=str(cwd), env=self.env, spaces=self.indent)
154
153
 
155
154
  def _run_post_exec(self, cwd: os.PathLike = Path(".")):
156
155
  self._initialize_data()
157
- if self["delete"] or not self.is_changed():
156
+ cmd = self["exec_after"]
157
+ if not cmd or self["delete"] or not self.is_changed():
158
158
  return
159
159
 
160
- for post_exec in self["exec_after"]:
161
- if not post_exec:
162
- continue
163
-
164
- self._run(post_exec, cwd=str(cwd), env=self.env,
165
- spaces=self.indent)
160
+ self._run(cmd, cwd=str(cwd), env=self.env, spaces=self.indent)
166
161
 
167
162
  def is_changed(self) -> bool:
168
163
  self._initialize_data()
@@ -195,6 +190,7 @@ class TaskBatchFetch(TaskBase):
195
190
  self.values["result"]["output"] += output
196
191
 
197
192
  def get_output(self) -> str:
193
+ """Return the output."""
198
194
  self._initialize_data()
199
195
  return str(self.values["result"]["output"])
200
196
 
@@ -32,8 +32,8 @@ from .batchfetch_base import BatchFetchError, TaskBatchFetch
32
32
  from .helpers import run_simple
33
33
 
34
34
 
35
- class GitReferenceDoesNotExist(Exception):
36
- """The Git reference does not exist."""
35
+ class GitRevisionDoesNotExist(Exception):
36
+ """The Git revision does not exist."""
37
37
 
38
38
 
39
39
  class GitRemoteError(Exception):
@@ -58,6 +58,7 @@ class BatchFetchGit(TaskBatchFetch):
58
58
  self.task_schema.update({
59
59
  # Local options
60
60
  self.main_key: str,
61
+ Optional("revision"): str,
61
62
  Optional("reference"): str,
62
63
 
63
64
  # Same as global options
@@ -77,7 +78,7 @@ class BatchFetchGit(TaskBatchFetch):
77
78
 
78
79
  self.task_default_values.update({
79
80
  self.main_key: "",
80
- "reference": "",
81
+ "revision": "",
81
82
  "delete": False,
82
83
  })
83
84
 
@@ -100,6 +101,11 @@ class BatchFetchGit(TaskBatchFetch):
100
101
  """Clone or update a Git repository."""
101
102
  super().update()
102
103
 
104
+ # Backward compatibility
105
+ if "reference" in self._item_values \
106
+ and not "revision" in self._item_values:
107
+ self._item_values["revision"] = "reference"
108
+
103
109
  is_clone = False
104
110
  if not self.git_local_dir.exists():
105
111
  is_clone = True
@@ -113,8 +119,8 @@ class BatchFetchGit(TaskBatchFetch):
113
119
  update_type = "UPDATE"
114
120
 
115
121
  self.add_output(f"[GIT {update_type}] {self[self.main_key]}" +
116
- (f" (Ref: {self['reference']})"
117
- if self["reference"] else "") + "\n")
122
+ (f" (Ref: {self['revision']})"
123
+ if self["revision"] else "") + "\n")
118
124
 
119
125
  try:
120
126
  # Delete
@@ -160,7 +166,7 @@ class BatchFetchGit(TaskBatchFetch):
160
166
  return self.values
161
167
 
162
168
  def _git_ref(self, cwd: Union[None, Path] = None) -> str:
163
- """Get the commit reference of HEAD.
169
+ """Get the commit revision of HEAD.
164
170
 
165
171
  The command will fail if the branch is detached.
166
172
  """
@@ -191,11 +197,11 @@ class BatchFetchGit(TaskBatchFetch):
191
197
  # If the tag is annotated, it points to a tag object, not
192
198
  # directly to a commit. You need to resolve it to the
193
199
  # commit it points to. Using `git rev-parse
194
- # <tagname>^{commit}` allows getting the right reference.
195
- commit_ref = self._git_tags(self["reference"] +
200
+ # <tagname>^{commit}` allows getting the right revision.
201
+ commit_ref = self._git_tags(self["revision"] +
196
202
  "^{commit}")[0]
197
203
  self.branch_commit_ref = commit_ref.strip()
198
- except GitReferenceDoesNotExist:
204
+ except GitRevisionDoesNotExist:
199
205
  pass
200
206
 
201
207
  def _repo_delete(self):
@@ -235,21 +241,21 @@ class BatchFetchGit(TaskBatchFetch):
235
241
  do_git_pull = self["git_pull"]
236
242
  if self.is_branch:
237
243
  do_git_pull = True
238
- elif not self["reference"]:
244
+ elif not self["revision"]:
239
245
  do_git_pull = True
240
246
  self.add_output(self.indent_spaces +
241
247
  "[INFO] Git fetch origin reason: " +
242
- "No 'reference:' specified\n")
248
+ "No 'revision:' specified\n")
243
249
  else:
244
250
  do_git_pull = False
245
251
  commit_ref = None
246
252
 
247
253
  try:
248
- # Check if the reference such as
254
+ # Check if the revision such as
249
255
  # 0560fe21d1173b2221fd8c600fab818f7eecbad4 exist
250
- commit_ref = self._git_tags(self["reference"])[0]
256
+ commit_ref = self._git_tags(self["revision"])[0]
251
257
  commit_ref = commit_ref.strip()
252
- except GitReferenceDoesNotExist:
258
+ except GitRevisionDoesNotExist:
253
259
  pass
254
260
 
255
261
  if not commit_ref and not self.is_branch:
@@ -257,19 +263,19 @@ class BatchFetchGit(TaskBatchFetch):
257
263
  self.add_output(
258
264
  self.indent_spaces +
259
265
  "[INFO] Git fetch origin reason: " +
260
- f"The reference does not exist: {self['reference']}" +
266
+ f"The revision does not exist: {self['revision']}" +
261
267
  "\n")
262
268
 
263
269
  if not do_git_pull:
264
270
  try:
265
271
  # Check if the branch is a tag or a branch
266
272
  cmd = ["git", "show-ref", "--verify", "--quiet",
267
- f"refs/heads/{self['reference']}"]
273
+ f"refs/heads/{self['revision']}"]
268
274
  run_simple(cmd, env=self.env, cwd=self.git_local_dir)
269
275
  self.add_output(
270
276
  self.indent_spaces +
271
277
  "[INFO] Git fetch origin reason:" +
272
- f"{self['reference']} is a branch, not a tag" +
278
+ f"{self['revision']} is a branch, not a tag" +
273
279
  "\n")
274
280
  do_git_pull = True
275
281
  except subprocess.CalledProcessError:
@@ -282,14 +288,14 @@ class BatchFetchGit(TaskBatchFetch):
282
288
  # not directly to a commit. You need to resolve it to
283
289
  # the commit it points to. Using `git rev-parse
284
290
  # <tagname>^{commit}` allows getting the right
285
- # reference.
291
+ # revision.
286
292
  commit_ref_head = self._git_tags("HEAD^{commit}")[0]
287
293
  commit_ref_head = commit_ref_head.strip()
288
- except GitReferenceDoesNotExist:
294
+ except GitRevisionDoesNotExist:
289
295
  # HEAD is detached
290
296
  commit_ref_head = None
291
297
 
292
- # The wanted commit reference does not exist
298
+ # The wanted commit revision does not exist
293
299
  # Or the commit ref of HEAD hasn't changed
294
300
  if not commit_ref_head or commit_ref_head != commit_ref:
295
301
  self.add_output(
@@ -395,46 +401,46 @@ class BatchFetchGit(TaskBatchFetch):
395
401
  error = True
396
402
 
397
403
  if error:
398
- raise GitReferenceDoesNotExist(
399
- f"The reference '{branch}' does not exist.")
404
+ raise GitRevisionDoesNotExist(
405
+ f"The revision '{branch}' does not exist.")
400
406
 
401
407
  return stdout
402
408
 
403
409
  def _repo_fix_branch(self) -> bool:
404
410
  git_ref_after_merge = self._git_ref(cwd=self.git_local_dir)
405
411
  branch_changed = False
406
- if self["reference"]:
412
+ if self["revision"]:
407
413
  # We also need tags because sometimes, a branch
408
- # returns a different commit reference
414
+ # returns a different commit revision
409
415
  git_tags, _ = run_simple(
410
416
  ["git", "tag", "--points-at", "HEAD"],
411
417
  env=self.env,
412
418
  cwd=self.git_local_dir,
413
419
  )
414
420
 
415
- # Also check the commit reference in case
416
- # branch is a commit reference instead of a tag
421
+ # Also check the commit revision in case
422
+ # branch is a commit revision instead of a tag
417
423
  try:
418
424
  # Check if the branch exists
419
425
  git_ref_branch = self._git_tags("origin/" +
420
- self["reference"] +
426
+ self["revision"] +
421
427
  "^{commit}")[0]
422
- except GitReferenceDoesNotExist as err:
428
+ except GitRevisionDoesNotExist as err:
423
429
  # Check if the commit ref exists
424
430
  try:
425
- git_ref_branch = self._git_tags(self["reference"])[0]
426
- except GitReferenceDoesNotExist as err:
427
- raise BatchFetchError(f"The branch '{self['reference']}' "
431
+ git_ref_branch = self._git_tags(self["revision"])[0]
432
+ except GitRevisionoesNotExist as err:
433
+ raise BatchFetchError(f"The branch '{self['revision']}' "
428
434
  "does not exist.") from err
429
435
 
430
436
  if git_ref_after_merge != git_ref_branch and \
431
- self["reference"] not in git_tags:
437
+ self["revision"] not in git_tags:
432
438
  # Update the branch
433
- self._run(["git", "checkout"] + [self["reference"]],
439
+ self._run(["git", "checkout"] + [self["revision"]],
434
440
  cwd=str(self.git_local_dir), env=self.env)
435
441
  self.add_output(self.indent_spaces +
436
442
  "[INFO] Branch changed to " +
437
- self["reference"] + "\n")
443
+ self["revision"] + "\n")
438
444
  self.set_changed(True)
439
445
  branch_changed = True
440
446
 
@@ -460,7 +466,7 @@ class BatchFetchGit(TaskBatchFetch):
460
466
  # 3. It does not directly consult the upstream repositories
461
467
  # of the submodules.
462
468
  # 4. Submodules are updated to reflect the exact commits
463
- # referenced in the parent repository's configuration,
469
+ # revision in the parent repository's configuration,
464
470
  # potentially lagging behind the latest changes made in the
465
471
  # upstream repositories.
466
472
  if self.git_local_dir.joinpath(".gitmodules").is_file():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batchfetch
3
- Version: 1.1.8
3
+ Version: 1.2.0
4
4
  Summary: Efficiently clone and pull multiple Git repositories.
5
5
  Home-page: https://github.com/jamescherti/batchfetch
6
6
  Author: James Cherti
@@ -17,10 +17,6 @@ Classifier: Topic :: Utilities
17
17
  Requires-Python: >=3.6, <4
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: colorama
21
- Requires-Dist: schema
22
- Requires-Dist: setproctitle
23
- Requires-Dist: PyYAML
24
20
 
25
21
  # Batchfetch - Efficiently clone or pull multiple Git repositories in parallel
26
22
 
@@ -61,12 +57,12 @@ tasks:
61
57
  # Clone the tag 1.5 of the consult repository to the './consult'
62
58
  # directory
63
59
  - git: https://github.com/minad/consult
64
- reference: "1.5"
60
+ revision: "1.5"
65
61
 
66
62
  # Clone the s.el repository to the './another-name.el' directory
67
63
  - git: https://github.com/magnars/s.el
68
64
  path: another-name.el
69
- reference: dda84d38fffdaf0c9b12837b504b402af910d01d
65
+ revision: dda84d38fffdaf0c9b12837b504b402af910d01d
70
66
 
71
67
  # Delete './impatient-mode'
72
68
  - git: https://github.com/skeeto/impatient-mode
@@ -22,7 +22,7 @@ from setuptools import find_packages, setup
22
22
 
23
23
  setup(
24
24
  name="batchfetch",
25
- version="1.1.8",
25
+ version="1.2.0",
26
26
  packages=find_packages(),
27
27
  description="Efficiently clone and pull multiple Git repositories.",
28
28
  license="GPLv3",
File without changes
File without changes
@@ -1,4 +1,4 @@
1
+ PyYAML
1
2
  colorama
2
3
  schema
3
4
  setproctitle
4
- PyYAML
File without changes
File without changes