batchfetch 1.2.8__tar.gz → 1.3.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.
- {batchfetch-1.2.8 → batchfetch-1.3.0}/PKG-INFO +16 -1
- {batchfetch-1.2.8 → batchfetch-1.3.0}/README.md +15 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch/batchfetch_base.py +27 -11
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch/batchfetch_cli.py +16 -6
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch/batchfetch_git.py +43 -46
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/PKG-INFO +16 -1
- {batchfetch-1.2.8 → batchfetch-1.3.0}/setup.py +1 -1
- {batchfetch-1.2.8 → batchfetch-1.3.0}/LICENSE +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch/__init__.py +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch/helpers.py +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/SOURCES.txt +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/dependency_links.txt +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/entry_points.txt +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/requires.txt +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/batchfetch.egg-info/top_level.txt +0 -0
- {batchfetch-1.2.8 → batchfetch-1.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: batchfetch
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -196,6 +196,21 @@ batchfetch easysession
|
|
|
196
196
|
|
|
197
197
|
This will execute only the task corresponding to the `easysession` path, skipping all others in the `batchfetch.yml` file.
|
|
198
198
|
|
|
199
|
+
### How can I configure batchfetch to load a file other than batchfetch.yaml?
|
|
200
|
+
|
|
201
|
+
You can specify the configuration file using the `-f` command-line option:
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
batchfetch -f alternative-batchfetch.yaml
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Alternatively, you can set the `BATCHFETCH_FILE` environment variable:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
export BATCHFETCH_FILE=alternative-batchfetch.yaml
|
|
211
|
+
batchfetch
|
|
212
|
+
```
|
|
213
|
+
|
|
199
214
|
## License
|
|
200
215
|
|
|
201
216
|
Copyright (C) 2024 [James Cherti](https://www.jamescherti.com)
|
|
@@ -176,6 +176,21 @@ batchfetch easysession
|
|
|
176
176
|
|
|
177
177
|
This will execute only the task corresponding to the `easysession` path, skipping all others in the `batchfetch.yml` file.
|
|
178
178
|
|
|
179
|
+
### How can I configure batchfetch to load a file other than batchfetch.yaml?
|
|
180
|
+
|
|
181
|
+
You can specify the configuration file using the `-f` command-line option:
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
batchfetch -f alternative-batchfetch.yaml
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Alternatively, you can set the `BATCHFETCH_FILE` environment variable:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
export BATCHFETCH_FILE=alternative-batchfetch.yaml
|
|
191
|
+
batchfetch
|
|
192
|
+
```
|
|
193
|
+
|
|
179
194
|
## License
|
|
180
195
|
|
|
181
196
|
Copyright (C) 2024 [James Cherti](https://www.jamescherti.com)
|
|
@@ -138,28 +138,44 @@ class TaskBatchFetch(TaskBase):
|
|
|
138
138
|
# Mark values as initialized
|
|
139
139
|
self._values_initialized = True
|
|
140
140
|
|
|
141
|
-
def
|
|
142
|
-
stdout = run_indent_str(
|
|
143
|
-
|
|
141
|
+
def _local_task_exec(self, *args, **kwargs):
|
|
142
|
+
stdout = run_indent_str(env=self.env, spaces=self.indent,
|
|
143
|
+
*args, **kwargs)
|
|
144
144
|
if not stdout.endswith("\n"):
|
|
145
145
|
stdout += "\n"
|
|
146
146
|
self.add_output(stdout)
|
|
147
147
|
|
|
148
|
-
def
|
|
148
|
+
def _exec_before(self, cwd: os.PathLike = Path(".")):
|
|
149
149
|
self._initialize_data()
|
|
150
|
-
|
|
151
|
-
if self["delete"] or not cmd:
|
|
150
|
+
if self["delete"]:
|
|
152
151
|
return
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
# Global
|
|
154
|
+
cmd = self.options["exec_before"] \
|
|
155
|
+
if "exec_before" in self.options else None
|
|
156
|
+
if cmd:
|
|
157
|
+
self._local_task_exec(cmd, cwd=str(cwd))
|
|
158
|
+
|
|
159
|
+
# Local
|
|
160
|
+
cmd = self["exec_before"]
|
|
161
|
+
if cmd:
|
|
162
|
+
self._local_task_exec(cmd, cwd=str(cwd))
|
|
155
163
|
|
|
156
|
-
def
|
|
164
|
+
def _exec_after(self, cwd: os.PathLike = Path(".")):
|
|
157
165
|
self._initialize_data()
|
|
158
|
-
|
|
159
|
-
if not cmd or self["delete"] or not self.is_changed():
|
|
166
|
+
if self["delete"] or not self.is_changed():
|
|
160
167
|
return
|
|
161
168
|
|
|
162
|
-
|
|
169
|
+
# Local
|
|
170
|
+
cmd = self.options["exec_after"] \
|
|
171
|
+
if "exec_after" in self.options else None
|
|
172
|
+
if cmd:
|
|
173
|
+
self._local_task_exec(cmd, cwd=str(cwd))
|
|
174
|
+
|
|
175
|
+
# Local
|
|
176
|
+
cmd = self["exec_after"]
|
|
177
|
+
if cmd:
|
|
178
|
+
self._local_task_exec(cmd, cwd=str(cwd))
|
|
163
179
|
|
|
164
180
|
def is_changed(self) -> bool:
|
|
165
181
|
self._initialize_data()
|
|
@@ -298,6 +298,12 @@ class BatchFetchCli:
|
|
|
298
298
|
|
|
299
299
|
def parse_args():
|
|
300
300
|
"""Parse the command line arguments."""
|
|
301
|
+
# Batchfetch file
|
|
302
|
+
try:
|
|
303
|
+
batchfetch_file = os.environ["BATCHFETCH_FILE"]
|
|
304
|
+
except KeyError:
|
|
305
|
+
batchfetch_file = None
|
|
306
|
+
|
|
301
307
|
# Jobs
|
|
302
308
|
try:
|
|
303
309
|
jobs = os.environ["BATCHFETCH_JOBS"]
|
|
@@ -326,12 +332,16 @@ def parse_args():
|
|
|
326
332
|
"paths defined in the batchfetch.yml list of tasks."),
|
|
327
333
|
)
|
|
328
334
|
|
|
329
|
-
parser.add_argument(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
parser.add_argument(
|
|
336
|
+
"-f",
|
|
337
|
+
"--file",
|
|
338
|
+
default=batchfetch_file,
|
|
339
|
+
required=False,
|
|
340
|
+
help=("Specify the batchfetch YAML file "
|
|
341
|
+
"(default: './batchfetch.yaml')."
|
|
342
|
+
"Alternatively, the BATCHFETCH_FILE environment variable can be "
|
|
343
|
+
"used to configure the number of jobs."),
|
|
344
|
+
)
|
|
335
345
|
|
|
336
346
|
parser.add_argument(
|
|
337
347
|
"-C",
|
|
@@ -59,7 +59,6 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
59
59
|
# Local options
|
|
60
60
|
self.main_key: str,
|
|
61
61
|
Optional("revision"): str,
|
|
62
|
-
Optional("reference"): str,
|
|
63
62
|
|
|
64
63
|
# Same as global options
|
|
65
64
|
Optional("git_clone_args"): [str],
|
|
@@ -104,11 +103,6 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
104
103
|
"""Clone or update a Git repository."""
|
|
105
104
|
super().update()
|
|
106
105
|
|
|
107
|
-
# Backward compatibility
|
|
108
|
-
if "reference" in self._item_values \
|
|
109
|
-
and "revision" not in self._item_values:
|
|
110
|
-
self._item_values["revision"] = "reference"
|
|
111
|
-
|
|
112
106
|
is_clone = False
|
|
113
107
|
if not self.git_local_dir.exists():
|
|
114
108
|
is_clone = True
|
|
@@ -139,9 +133,20 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
139
133
|
# Pre exec
|
|
140
134
|
self._update_current_branch_name()
|
|
141
135
|
self._repo_fix_remote_origin()
|
|
142
|
-
self.
|
|
136
|
+
self._exec_before(cwd=self.git_local_dir)
|
|
137
|
+
|
|
138
|
+
if not self["revision"]:
|
|
139
|
+
self.values["revision"] = self._run_get_firstline(
|
|
140
|
+
"git symbolic-ref refs/remotes/origin/HEAD"
|
|
141
|
+
).split("/")[-1]
|
|
142
|
+
if not self["revision"]:
|
|
143
|
+
raise BatchFetchError(
|
|
144
|
+
"Unable to determine the default origin branch"
|
|
145
|
+
)
|
|
143
146
|
|
|
144
|
-
|
|
147
|
+
self.add_output(self.indent_spaces +
|
|
148
|
+
f"[INFO] Update revision to: '" +
|
|
149
|
+
self["revision"] + "'\n")
|
|
145
150
|
|
|
146
151
|
git_fetch_done = self._repo_fetch()
|
|
147
152
|
|
|
@@ -152,11 +157,8 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
152
157
|
if git_fetch_done:
|
|
153
158
|
git_merge_done = self._git_merge()
|
|
154
159
|
|
|
155
|
-
# if (git_fetch_done and git_merge_done) or git_branch_changed:
|
|
156
|
-
# self._repo_update_submodules()
|
|
157
|
-
|
|
158
160
|
if self.get_changed():
|
|
159
|
-
self.
|
|
161
|
+
self._exec_after(cwd=self.git_local_dir)
|
|
160
162
|
except BatchFetchError as err:
|
|
161
163
|
self.set_error(True)
|
|
162
164
|
self.add_output(self.indent_spaces + "[ERROR] " + str(err) + "\n")
|
|
@@ -173,6 +175,13 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
173
175
|
|
|
174
176
|
return self.values
|
|
175
177
|
|
|
178
|
+
def _run_get_firstline(self, *args, **kwargs):
|
|
179
|
+
stdout, _ = self._run(*args, **kwargs)
|
|
180
|
+
try:
|
|
181
|
+
return stdout[0]
|
|
182
|
+
except IndexError:
|
|
183
|
+
return ""
|
|
184
|
+
|
|
176
185
|
def _run(self, cmd: Union[List[str], str],
|
|
177
186
|
cwd: Union[None, os.PathLike] = None,
|
|
178
187
|
env: Union[None, dict] = None,
|
|
@@ -251,50 +260,38 @@ class BatchFetchGit(TaskBatchFetch):
|
|
|
251
260
|
self._run(cmd, cwd=".")
|
|
252
261
|
self.set_changed(True)
|
|
253
262
|
|
|
254
|
-
def _repo_reset(self):
|
|
255
|
-
# Remove local changes
|
|
256
|
-
cmd = ["git", "reset", "--hard", "HEAD"]
|
|
257
|
-
self._run(cmd, cwd=".")
|
|
258
|
-
|
|
259
263
|
def _repo_fetch(self):
|
|
260
264
|
# Merge
|
|
261
265
|
do_git_fetch = self["git_pull"]
|
|
262
|
-
|
|
266
|
+
do_git_fetch = False
|
|
267
|
+
commit_ref = None
|
|
268
|
+
|
|
269
|
+
try:
|
|
270
|
+
# Check if the revision such as
|
|
271
|
+
stdout, _ = self._run(["git", "cat-file", "-e", self["revision"]])
|
|
272
|
+
except subprocess.CalledProcessError:
|
|
263
273
|
do_git_fetch = True
|
|
264
|
-
self.add_output(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
commit_ref = None
|
|
274
|
+
self.add_output(
|
|
275
|
+
self.indent_spaces
|
|
276
|
+
+ "[INFO] Git fetch origin reason: "
|
|
277
|
+
+ f"The revision does not exist: {self['revision']}"
|
|
278
|
+
+ "\n")
|
|
270
279
|
|
|
280
|
+
# The revision exists, but if it a branch, git pull anyway
|
|
281
|
+
if not do_git_fetch:
|
|
271
282
|
try:
|
|
272
|
-
# Check if the
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
do_git_fetch = True
|
|
283
|
+
# Check if the branch is a tag or a branch
|
|
284
|
+
cmd = ["git", "show-ref", "--verify", "--quiet",
|
|
285
|
+
f"refs/heads/{self['revision']}"]
|
|
286
|
+
self._run(cmd)
|
|
277
287
|
self.add_output(
|
|
278
288
|
self.indent_spaces
|
|
279
289
|
+ "[INFO] Git fetch origin reason: "
|
|
280
|
-
+ f"
|
|
290
|
+
+ f"{self['revision']} is a branch, not a tag"
|
|
281
291
|
+ "\n")
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
try:
|
|
286
|
-
# Check if the branch is a tag or a branch
|
|
287
|
-
cmd = ["git", "show-ref", "--verify", "--quiet",
|
|
288
|
-
f"refs/heads/{self['revision']}"]
|
|
289
|
-
self._run(cmd)
|
|
290
|
-
self.add_output(
|
|
291
|
-
self.indent_spaces
|
|
292
|
-
+ "[INFO] Git fetch origin reason: "
|
|
293
|
-
+ f"{self['revision']} is a branch, not a tag"
|
|
294
|
-
+ "\n")
|
|
295
|
-
do_git_fetch = True
|
|
296
|
-
except subprocess.CalledProcessError:
|
|
297
|
-
pass
|
|
292
|
+
do_git_fetch = True
|
|
293
|
+
except subprocess.CalledProcessError:
|
|
294
|
+
pass
|
|
298
295
|
|
|
299
296
|
if not do_git_fetch:
|
|
300
297
|
self.add_output(self.indent_spaces + "[INFO] git fetch ignored\n")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: batchfetch
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -196,6 +196,21 @@ batchfetch easysession
|
|
|
196
196
|
|
|
197
197
|
This will execute only the task corresponding to the `easysession` path, skipping all others in the `batchfetch.yml` file.
|
|
198
198
|
|
|
199
|
+
### How can I configure batchfetch to load a file other than batchfetch.yaml?
|
|
200
|
+
|
|
201
|
+
You can specify the configuration file using the `-f` command-line option:
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
batchfetch -f alternative-batchfetch.yaml
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Alternatively, you can set the `BATCHFETCH_FILE` environment variable:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
export BATCHFETCH_FILE=alternative-batchfetch.yaml
|
|
211
|
+
batchfetch
|
|
212
|
+
```
|
|
213
|
+
|
|
199
214
|
## License
|
|
200
215
|
|
|
201
216
|
Copyright (C) 2024 [James Cherti](https://www.jamescherti.com)
|
|
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
|