batchfetch 1.0.6__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.
- {batchfetch-1.0.6 → batchfetch-1.0.8}/PKG-INFO +1 -1
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch/batchfetch_base.py +8 -8
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch/batchfetch_cli.py +16 -12
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch/batchfetch_git.py +26 -18
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/PKG-INFO +1 -1
- {batchfetch-1.0.6 → batchfetch-1.0.8}/setup.py +1 -1
- {batchfetch-1.0.6 → batchfetch-1.0.8}/LICENSE +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/README.md +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch/__init__.py +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch/helpers.py +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/SOURCES.txt +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/dependency_links.txt +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/entry_points.txt +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/requires.txt +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/batchfetch.egg-info/top_level.txt +0 -0
- {batchfetch-1.0.6 → batchfetch-1.0.8}/setup.cfg +0 -0
|
@@ -41,21 +41,21 @@ class BatchFetchBase:
|
|
|
41
41
|
|
|
42
42
|
# Default
|
|
43
43
|
self.global_options_schema: Dict[Any, Any] = {
|
|
44
|
-
Optional("
|
|
45
|
-
Optional("
|
|
44
|
+
Optional("exec_before"): Or([str], str),
|
|
45
|
+
Optional("exec_after"): Or([str], str),
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
self.item_schema: Dict[Any, Any] = {
|
|
49
49
|
Optional("path"): str,
|
|
50
50
|
Optional("delete"): bool,
|
|
51
51
|
|
|
52
|
-
Optional("
|
|
53
|
-
Optional("
|
|
52
|
+
Optional("exec_before"): Or([str], str),
|
|
53
|
+
Optional("exec_after"): Or([str], str),
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
self.global_options_values: Dict[str, Any] = {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
57
|
+
"exec_before": [],
|
|
58
|
+
"exec_after": [],
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
self.item_default_values: Dict[str, Any] = {
|
|
@@ -112,7 +112,7 @@ class BatchFetchBase:
|
|
|
112
112
|
|
|
113
113
|
def _run_pre_exec(self, cwd: os.PathLike = Path(".")):
|
|
114
114
|
self._initialize_data()
|
|
115
|
-
for pre_exec in self["
|
|
115
|
+
for pre_exec in self["exec_before"]:
|
|
116
116
|
if not pre_exec:
|
|
117
117
|
continue
|
|
118
118
|
|
|
@@ -124,7 +124,7 @@ class BatchFetchBase:
|
|
|
124
124
|
if self["delete"] or not self.is_changed():
|
|
125
125
|
return
|
|
126
126
|
|
|
127
|
-
for post_exec in self["
|
|
127
|
+
for post_exec in self["exec_after"]:
|
|
128
128
|
if not post_exec:
|
|
129
129
|
continue
|
|
130
130
|
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
print(Fore.YELLOW, end="")
|
|
169
|
+
error = True
|
|
170
|
+
failed.append(data)
|
|
172
171
|
else:
|
|
173
|
-
|
|
174
|
-
continue
|
|
172
|
+
num_success += 1
|
|
175
173
|
|
|
176
|
-
|
|
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
|
-
|
|
180
|
-
|
|
180
|
+
print(Fore.RED, end="")
|
|
181
|
+
elif data["result"]["changed"]:
|
|
182
|
+
print(Fore.YELLOW, end="")
|
|
181
183
|
else:
|
|
182
|
-
|
|
184
|
+
print(Fore.GREEN, end="")
|
|
183
185
|
|
|
184
186
|
if data["result"]["output"]:
|
|
185
187
|
print(data["result"]["output"].rstrip("\n"))
|
|
@@ -229,6 +231,8 @@ def parse_args():
|
|
|
229
231
|
)
|
|
230
232
|
|
|
231
233
|
args = parser.parse_args()
|
|
234
|
+
if not args.batchfetch_files:
|
|
235
|
+
args.batchfetch_files = ["./batchfetch.yaml"]
|
|
232
236
|
|
|
233
237
|
for batchfetch_file in args.batchfetch_files:
|
|
234
238
|
if not Path(batchfetch_file).is_file():
|
|
@@ -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" (
|
|
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
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|