@@ -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
132132def 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
158161def new (args ):
@@ -186,12 +189,14 @@ def new(args):
186189
187190def 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
210215def 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