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

Commit 0a7b076

Browse files
committed
Delete the merge branch if merge successful
Also give some better error messages and docs
1 parent c275589 commit 0a7b076

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ It integrates the following tools:
2222
- Pytest for code and coverage
2323
- Sphinx for tutorials, how-to guides, explanations and reference documentation
2424
- GitHub Actions for code and docs CI and deployment to PyPI and GitHub Pages
25-
- VSCode settings using black, flake8, isort and mypy on save
25+
- If you use VSCode, it will run black, flake8, isort and mypy on save
2626

2727
The ``skeleton`` branch of this module contains the source code that can be
2828
merged into new or existing projects, and pulled from to keep them up to date.
29+
It can also serve as a working example for those who would prefer to
30+
cherry-pick.
2931

3032
The ``master`` branch contains the
3133
docs and a command line tool to ease the adoption of this skeleton into new::

src/dls_python3_skeleton/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,19 @@ def merge_skeleton(
9595
# The merge failed, so ask the user to fix it
9696
print("Please fix the conflicts above, then you can run:")
9797
print(f" git branch -d {MERGE_BRANCH}")
98+
else:
99+
git("branch", "-d", MERGE_BRANCH, cwd=path)
98100
print("Instructions on how to develop this module are in CONTRIBUTING.rst")
99101

100102

101103
def new(args):
102104
path: Path = args.path
103-
path.mkdir(parents=True)
105+
if path.exists():
106+
assert path.is_dir() and not list(
107+
path.iterdir()
108+
), f"Expected {path} to not exist, or be an empty dir"
109+
else:
110+
path.mkdir(parents=True)
104111
git("init", cwd=path)
105112
print(f"Created git repo in {path}")
106113
merge_skeleton(
@@ -114,6 +121,7 @@ def new(args):
114121

115122
def existing(args):
116123
path: Path = args.path
124+
assert path.is_dir(), f"Expected {path} to be an existing directory"
117125
conf = ConfigParser()
118126
conf.read(path / "setup.cfg")
119127
merge_skeleton(

tests/test_dls_python3_skeleton.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def test_new_module(tmp_path: Path):
4343
assert conf["metadata"]["author"] == "Firstname Lastname"
4444
assert conf["metadata"]["author_email"] == "[email protected]"
4545
assert (module / "src" / "my_module").is_dir()
46+
assert check_output("git", "branch", cwd=module).strip() == "* master"
4647
check_output("pipenv", "install", "--dev", cwd=module)
4748
check_output("pipenv", "run", "docs", cwd=module)
4849
with pytest.raises(ValueError) as ctx:

0 commit comments

Comments
 (0)