batchfetch 1.0.7__tar.gz → 1.0.8__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.1
2
2
  Name: batchfetch
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Efficiently clone and pull multiple Git repositories.
5
5
  Home-page: https://github.com/jamescherti/batchfetch
6
6
  Author: James Cherti
@@ -43,7 +43,7 @@ class BatchFetchCli:
43
43
  def __init__(self, max_workers: int, verbose: bool = False):
44
44
  self.cfg: dict = {}
45
45
  self.folder = Path(".")
46
- self.managed_filenames: Set[str] = set()
46
+ self.managed_paths: Set[Path] = set()
47
47
  self.verbose = verbose
48
48
  self.max_workers = max_workers
49
49
  self._logger = logging.getLogger(self.__class__.__name__)
@@ -149,7 +149,7 @@ class BatchFetchCli:
149
149
  error = False
150
150
  threads = []
151
151
  num_success = 0
152
- self.managed_filenames = set()
152
+ self.managed_paths = set()
153
153
 
154
154
  executor_update = ThreadPoolExecutor(max_workers=self.max_workers)
155
155
 
@@ -160,26 +160,28 @@ class BatchFetchCli:
160
160
  for task in all_tasks:
161
161
  self.dirs_relative_to_batchfetch.add(str(task["path"]))
162
162
  if not task["delete"]:
163
- self.managed_filenames.add(task["path"])
163
+ self.managed_paths.add(Path(task["path"]).absolute())
164
164
  threads.append(executor_update.submit(task.update))
165
165
 
166
166
  for future in as_completed(threads):
167
167
  data = future.result()
168
168
  if data["result"]["error"]:
169
- print(Fore.RED, end="")
170
- elif data["result"]["changed"]:
171
- print(Fore.YELLOW, end="")
169
+ error = True
170
+ failed.append(data)
172
171
  else:
173
- if not self.verbose:
174
- continue
172
+ num_success += 1
175
173
 
176
- print(Fore.GREEN, end="")
174
+ if (not self.verbose and
175
+ not data["result"]["error"] and
176
+ not data["result"]["changed"]):
177
+ continue
177
178
 
178
179
  if data["result"]["error"]:
179
- error = True
180
- failed.append(data)
180
+ print(Fore.RED, end="")
181
+ elif data["result"]["changed"]:
182
+ print(Fore.YELLOW, end="")
181
183
  else:
182
- num_success += 1
184
+ print(Fore.GREEN, end="")
183
185
 
184
186
  if data["result"]["output"]:
185
187
  print(data["result"]["output"].rstrip("\n"))
@@ -119,7 +119,7 @@ class BatchFetchGit(BatchFetchBase):
119
119
 
120
120
  self.add_output(
121
121
  f"[GIT {update_type}] {self[self.main_key]}" +
122
- (f" (Reference: {self['reference']})"
122
+ (f" (Ref: {self['reference']})"
123
123
  if self["reference"] else "") + "\n"
124
124
  )
125
125
 
@@ -218,27 +218,35 @@ class BatchFetchGit(BatchFetchBase):
218
218
  try:
219
219
  self._git_tags(self["reference"])
220
220
  except GitReferenceDoesNotExist:
221
- pass
221
+ # The reference does not exist. We should maybe git pull
222
+ # in case the reference is in a new commit.
223
+ ignore_git_pull = False
222
224
  else:
223
- # The branch exists:
224
- # 1. Ignore Git pull when the git reference is the same
225
- # as the "branch:" key
226
- try:
227
- commit_ref = self._git_ref(cwd=self.git_local_dir)
228
- except subprocess.CalledProcessError:
229
- # Ignore git pull because the head is detached
230
- pass
225
+ if self.current_branch and \
226
+ self.current_branch == self["reference"]:
227
+ ignore_git_pull = False
231
228
  else:
232
- if (self.current_branch and
233
- (commit_ref == self["reference"] or
234
- self.current_branch == self["reference"])):
229
+ # The reference exists:
230
+ # 1. Ignore Git pull when the git reference is the same
231
+ # as the "branch:" key
232
+ try:
233
+ commit_ref = self._git_ref(cwd=self.git_local_dir)
234
+ except subprocess.CalledProcessError:
235
+ # Ignore git pull because the head is detached
236
+ pass
237
+ else:
238
+ # The head is not detached
239
+ # self.current_branch contains the current branch
240
+ if (commit_ref == self["reference"] or
241
+ (self.current_branch and
242
+ self.current_branch == self["reference"])):
243
+ ignore_git_pull = True
244
+
245
+ # 2. Ignore Git pull if it is not a local branch
246
+ if (not ignore_git_pull and
247
+ not self._git_is_local_branch(self["reference"])):
235
248
  ignore_git_pull = True
236
249
 
237
- # 2. Ignore Git pull if it is not a local branch
238
- if (not ignore_git_pull and
239
- not self._git_is_local_branch(self["reference"])):
240
- ignore_git_pull = True
241
-
242
250
  if ignore_git_pull:
243
251
  self.add_output(self.indent_spaces +
244
252
  "[INFO] git pull ignored\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batchfetch
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Efficiently clone and pull multiple Git repositories.
5
5
  Home-page: https://github.com/jamescherti/batchfetch
6
6
  Author: James Cherti
@@ -22,7 +22,7 @@ from setuptools import find_packages, setup
22
22
 
23
23
  setup(
24
24
  name="batchfetch",
25
- version="1.0.7",
25
+ version="1.0.8",
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
File without changes