Skip to content

Commit d6b4874

Browse files
committed
Lint & bugfix
1 parent cf55f6b commit d6b4874

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

go_modules

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def extract(filename, outdir):
194194

195195
os.chdir(cwd)
196196

197+
197198
def pack(files: list, workdir: os.PathLike, mtime: float, args: dict):
198199
archive_args = get_archive_parameters(args)
199200
outdir = args.outdir
@@ -219,20 +220,19 @@ def pack(files: list, workdir: os.PathLike, mtime: float, args: dict):
219220
) as new_archive:
220221
try:
221222
for file in files:
222-
new_archive.add_files(
223-
file, mtime=mtime, ctime=mtime, atime=mtime
224-
)
223+
new_archive.add_files(file, mtime=mtime, ctime=mtime, atime=mtime)
225224
except (
226225
TypeError
227226
): # If using old libarchive fallback to old non reproducible behavior
228227
log.warning(
229228
"python libarchive is too old, unable to produce reproducible output"
230229
)
231230
for file in files:
232-
new_archive.add_files(files)
231+
new_archive.add_files(file)
233232
os.chdir(cwd)
234233

235-
def cmd_go_mod(subcmd, moddir, goenv = None):
234+
235+
def cmd_go_mod(subcmd, moddir, goenv=None):
236236
"""Execute go mod subcommand using subprocess.run().
237237
Capture both stderr and stdout as text.
238238
Log as info or error in this function body.
@@ -419,12 +419,7 @@ def main():
419419
if modified:
420420
files.extend(["go.mod", "go.sum"])
421421

422-
pack(
423-
files = files,
424-
workdir = go_mod_dir,
425-
mtime = go_mod_mtime,
426-
args = args
427-
)
422+
pack(files=files, workdir=go_mod_dir, mtime=go_mod_mtime, args=args)
428423

429424
elif args.strategy == "gomodcache":
430425
# Tars the GOMODCACHE dir only. Does not run 'go mod vendor'
@@ -434,7 +429,7 @@ def main():
434429

435430
gomodcache_dir = DEFAULT_MODCACHE_STEM
436431
gomodcache_path = os.path.join(tempdir, gomodcache_dir)
437-
goenv = { "GOMODCACHE": gomodcache_path }
432+
goenv = {"GOMODCACHE": gomodcache_path}
438433

439434
# return value cp is type subprocess.CompletedProcess
440435
cp = cmd_go_mod(["download"], go_mod_dir, goenv)
@@ -456,12 +451,7 @@ def main():
456451
exit(1)
457452

458453
cache_dir = os.path.join(gomodcache_dir, "cache")
459-
pack(
460-
files = [cache_dir],
461-
workdir = tempdir,
462-
mtime = go_mod_mtime,
463-
args = args
464-
)
454+
pack(files=[cache_dir], workdir=tempdir, mtime=go_mod_mtime, args=args)
465455

466456
if modified:
467457
log.info("Copy modified go.mod & go.sum to source dir")
@@ -472,8 +462,8 @@ def main():
472462
log.error(f"Unknown strategy `{args.strategy}`")
473463
exit(1)
474464

465+
475466
if __name__ == "__main__":
476467
logging.basicConfig(level=logging.DEBUG)
477468
log = logging.getLogger(app_name)
478469
main()
479-

0 commit comments

Comments
 (0)