Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit c0b41f8

Browse files
authored
Merge pull request #16 from epics-containers/dev
add note re --force
2 parents 721c104 + 71a0853 commit c0b41f8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/python3_pip_skeleton/__main__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def replace_text(text: str) -> str:
9090
git_tmp("pull", SKELETON, "main")
9191
# Move things around
9292
git_tmp("mv", "src/python3_pip_skeleton", f"src/{package}")
93-
git_tmp("mv", "tests/test_dls_python3_skeleton.py", f"tests/test_{package}.py")
93+
git_tmp("mv", "tests/test_cli.py", f"tests/test_{package}.py")
9494
# Change contents of all children known to git
9595
for relative_child in git_tmp("ls-files").splitlines():
9696
child = Path(git_tmp.name) / relative_child
@@ -130,7 +130,8 @@ def replace_text(text: str) -> str:
130130

131131

132132
def validate_package(args) -> str:
133-
package = args.package or args.path.name
133+
path = args.path.resolve()
134+
package = args.package or path.name
134135
valid = re.match("[a-zA-Z][a-zA-Z_0-9]*$", package)
135136
assert valid, f"'{package}' is not a valid python package name"
136137
return package
@@ -152,7 +153,9 @@ def verify_not_adopted(root: Path):
152153
]
153154
)
154155

155-
assert not_adopted, f"Package {root} has already adopted skeleton"
156+
assert (
157+
not_adopted
158+
), f"Package {root} has already adopted skeleton. use --force to re-adopt"
156159

157160

158161
def new(args):
@@ -186,12 +189,14 @@ def new(args):
186189

187190
def existing(args):
188191
path: Path = args.path
192+
path = path.resolve()
189193

190194
assert path.is_dir(), f"Expected {path} to be an existing directory"
191195
package = validate_package(args)
192196
file_path: Path = path / "setup.cfg"
193197
assert file_path.is_file(), "Expected a setup.cfg file in the directory."
194-
verify_not_adopted(args.path)
198+
if not args.force:
199+
verify_not_adopted(args.path)
195200

196201
conf = ConfigParser()
197202
conf.read(path / "setup.cfg")
@@ -209,6 +214,7 @@ def existing(args):
209214

210215
def clean_repo(args):
211216
path: Path = args.path
217+
path = path.resolve()
212218

213219
assert path.is_dir(), f"Expected {path} to be an existing directory"
214220

@@ -243,6 +249,7 @@ def main(args=None):
243249
sub = subparsers.add_parser("existing", help="Adopt skeleton in existing repo")
244250
sub.set_defaults(func=existing)
245251
sub.add_argument("path", type=Path, help="Path to new repo to existing repo")
252+
sub.add_argument("--force", action="store_true", help="force readoption")
246253
sub.add_argument("--org", required=True, help="GitHub organization for the repo")
247254
sub.add_argument(
248255
"--package", default=None, help="Package name, defaults to directory name"

0 commit comments

Comments
 (0)