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

Commit eb92586

Browse files
OCoppingcoretl
authored andcommitted
Added clean_repo method to delete the skeleton-merge-branch if it exists
1 parent c956f40 commit eb92586

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/dls_python3_skeleton/__main__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ def existing(args):
179179
)
180180

181181

182+
def clean_repo(args):
183+
path: Path = args.path
184+
185+
assert path.is_dir(), f"Expected {path} to be an existing directory"
186+
187+
branches = [x[2:] for x in str(git("branch", "--list")).split("\n")]
188+
assert "skeleton-merge-branch" in branches, \
189+
"Expected skeleton-merge-branch to be in existing repo"
190+
191+
git("branch", "-D", "skeleton-merge-branch")
192+
print("skeleton-merge-branch deleted from existing repo")
193+
194+
182195
def main(args=None):
183196
parser = ArgumentParser()
184197
subparsers = parser.add_subparsers()
@@ -209,6 +222,10 @@ def main(args=None):
209222
sub.add_argument(
210223
"--package", default=None, help="Package name, defaults to directory name"
211224
)
225+
# Add a command for cleaning an existing repo of skeleton code
226+
sub = subparsers.add_parser("clean", help="Clean skeleton from existing repo")
227+
sub.set_defaults(func=clean_repo)
228+
sub.add_argument("path", type=Path, help="Path to existing repo with skeleton code")
212229
# Parse args and run
213230
args = parser.parse_args(args)
214231
args.func(args)

0 commit comments

Comments
 (0)