Skip to content

Commit

Permalink
unarchive: simple fixes/cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
lowell80 committed Jan 4, 2024
1 parent 665b374 commit 818f918
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Renames:
- ``ksconf/commands/__init__.py`` -> ``ksconf/command.py``


Ksconf v0.13.9 (DRAFT)
Ksconf v0.13.9 (2024-01-04)
~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Fix app deployment bug that can occur if a previously deployed path changes from a file to a directory.
Expand Down
38 changes: 20 additions & 18 deletions ksconf/commands/unarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,28 @@

# XXX: Update code base to use ksconf.layer, as was done for the 'ksconf combine' command.

# XXX: Use AppManifest to make a content hash of the file being imported... (capture in git message)

DEFAULT_DIR = "default"


def fixup_pattern_bw(patterns, prefix=None):
modified = []
for pattern in patterns:
if pattern.startswith("./"):
if prefix:
pattern = f"{prefix}/{pattern[2:]}"
else:
pattern = pattern[2:]
modified.append(pattern)
# If a pattern like 'tags.conf' or '*.bak' is provided, use basename match (any dir)
elif "/" not in pattern:
modified.append("(^|.../)" + pattern)
else:
modified.append(pattern)
return modified


class UnarchiveCmd(KsconfCmd):
help = "Install or upgrade an existing app in a git-friendly and safe way"
description = dedent("""
Expand Down Expand Up @@ -179,16 +197,16 @@ def run(self, args):
f"'{app_name}' will be extracted as '{new_app_name}'\n")

app_basename = new_app_name or app_name
dest_app: Path = dest / app_basename
dest_app = Path(dest, app_basename)
self.stdout.write(f"Inspecting destination folder: {dest_app.absolute()}\n")

# FEEDBACK TO THE USER: UPGRADE VS INSTALL, GIT?, APP RENAME, ...
app_name_msg = app_name

is_git = False
git_ver = git_version()
if git_ver is None:
vc_msg = "without version control support (git not present)"
is_git = False
else:
vc_msg = "without version control support"

Expand Down Expand Up @@ -277,22 +295,6 @@ def show_pkg_info(facts: AppFacts, label):
elif is_git:
self.stdout.write("Git clean check skipped. Not needed for a fresh app install.\n")

def fixup_pattern_bw(patterns, prefix=None):
modified = []
for pattern in patterns:
if pattern.startswith("./"):
if prefix:
pattern = f"{prefix}/{pattern[2:]}"
else:
pattern = pattern[2:]
modified.append(pattern)
# If a pattern like 'tags.conf' or '*.bak' is provided, use basename match (any dir)
elif "/" not in pattern:
modified.append("(^|.../)" + pattern)
else:
modified.append(pattern)
return modified

# PREP ARCHIVE EXTRACTION
installed_files = set()
excludes = list(args.exclude)
Expand Down

0 comments on commit 818f918

Please sign in to comment.