@@ -90,7 +90,7 @@ def replace_text(text: str) -> str:
90
90
git_tmp ("pull" , SKELETON , "main" )
91
91
# Move things around
92
92
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" )
94
94
# Change contents of all children known to git
95
95
for relative_child in git_tmp ("ls-files" ).splitlines ():
96
96
child = Path (git_tmp .name ) / relative_child
@@ -130,7 +130,8 @@ def replace_text(text: str) -> str:
130
130
131
131
132
132
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
134
135
valid = re .match ("[a-zA-Z][a-zA-Z_0-9]*$" , package )
135
136
assert valid , f"'{ package } ' is not a valid python package name"
136
137
return package
@@ -152,7 +153,9 @@ def verify_not_adopted(root: Path):
152
153
]
153
154
)
154
155
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"
156
159
157
160
158
161
def new (args ):
@@ -186,12 +189,14 @@ def new(args):
186
189
187
190
def existing (args ):
188
191
path : Path = args .path
192
+ path = path .resolve ()
189
193
190
194
assert path .is_dir (), f"Expected { path } to be an existing directory"
191
195
package = validate_package (args )
192
196
file_path : Path = path / "setup.cfg"
193
197
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 )
195
200
196
201
conf = ConfigParser ()
197
202
conf .read (path / "setup.cfg" )
@@ -209,6 +214,7 @@ def existing(args):
209
214
210
215
def clean_repo (args ):
211
216
path : Path = args .path
217
+ path = path .resolve ()
212
218
213
219
assert path .is_dir (), f"Expected { path } to be an existing directory"
214
220
@@ -243,6 +249,7 @@ def main(args=None):
243
249
sub = subparsers .add_parser ("existing" , help = "Adopt skeleton in existing repo" )
244
250
sub .set_defaults (func = existing )
245
251
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" )
246
253
sub .add_argument ("--org" , required = True , help = "GitHub organization for the repo" )
247
254
sub .add_argument (
248
255
"--package" , default = None , help = "Package name, defaults to directory name"
0 commit comments