batchfetch 1.2.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batchfetch
3
- Version: 1.2.9
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 _pre_run(self, *args, **kwargs):
142
- stdout = run_indent_str(*args, **kwargs)
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 _run_pre_exec(self, cwd: os.PathLike = Path(".")):
148
+ def _exec_before(self, cwd: os.PathLike = Path(".")):
149
149
  self._initialize_data()
150
- cmd = self["exec_before"]
151
- if self["delete"] or not cmd:
150
+ if self["delete"]:
152
151
  return
153
152
 
154
- self._pre_run(cmd, cwd=str(cwd), env=self.env, spaces=self.indent)
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 _run_post_exec(self, cwd: os.PathLike = Path(".")):
164
+ def _exec_after(self, cwd: os.PathLike = Path(".")):
157
165
  self._initialize_data()
158
- cmd = self["exec_after"]
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
- self._pre_run(cmd, cwd=str(cwd), env=self.env, spaces=self.indent)
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("-f",
330
- "--file",
331
- default=None,
332
- required=False,
333
- help=("Specify the batchfetch YAML file "
334
- "(default: './batchfetch.yaml')."))
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",
@@ -133,7 +133,7 @@ class BatchFetchGit(TaskBatchFetch):
133
133
  # Pre exec
134
134
  self._update_current_branch_name()
135
135
  self._repo_fix_remote_origin()
136
- self._run_pre_exec(cwd=self.git_local_dir)
136
+ self._exec_before(cwd=self.git_local_dir)
137
137
 
138
138
  if not self["revision"]:
139
139
  self.values["revision"] = self._run_get_firstline(
@@ -158,7 +158,7 @@ class BatchFetchGit(TaskBatchFetch):
158
158
  git_merge_done = self._git_merge()
159
159
 
160
160
  if self.get_changed():
161
- self._run_post_exec(cwd=self.git_local_dir)
161
+ self._exec_after(cwd=self.git_local_dir)
162
162
  except BatchFetchError as err:
163
163
  self.set_error(True)
164
164
  self.add_output(self.indent_spaces + "[ERROR] " + str(err) + "\n")
@@ -268,8 +268,7 @@ class BatchFetchGit(TaskBatchFetch):
268
268
 
269
269
  try:
270
270
  # Check if the revision such as
271
- stdout, _ = self._run(["git", "cat-file", "-e",
272
- self["revision"]])
271
+ stdout, _ = self._run(["git", "cat-file", "-e", self["revision"]])
273
272
  except subprocess.CalledProcessError:
274
273
  do_git_fetch = True
275
274
  self.add_output(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batchfetch
3
- Version: 1.2.9
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)
@@ -22,7 +22,7 @@ from setuptools import find_packages, setup
22
22
 
23
23
  setup(
24
24
  name="batchfetch",
25
- version="1.2.9",
25
+ version="1.3.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