-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from LeastAuthority/report-git-failure-output
Report git's output when git fails
- Loading branch information
Showing
3 changed files
with
57 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
towncrier.check now reports git output when it encounters a git failure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,47 @@ | |
from towncrier.check import _main | ||
|
||
|
||
def create_project(pyproject_path): | ||
with open(pyproject_path, "w") as f: | ||
f.write("[tool.towncrier]\n" 'package = "foo"\n') | ||
os.mkdir("foo") | ||
with open("foo/__init__.py", "w") as f: | ||
f.write('__version__ = "1.2.3"\n') | ||
os.mkdir("foo/newsfragments") | ||
fragment_path = "foo/newsfragments/123.feature" | ||
with open(fragment_path, "w") as f: | ||
f.write("Adds levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
call(["git", "checkout", "-b", "otherbranch"]) | ||
|
||
|
||
class TestChecker(TestCase): | ||
maxDiff = None | ||
|
||
def test_git_fails(self): | ||
""" | ||
If git fails to report a comparison, git's output is reported to aid in | ||
debugging the situation. | ||
""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
create_project("pyproject.toml") | ||
|
||
result = runner.invoke(_main, ["--compare-with", "hblaugh"]) | ||
self.assertIn( | ||
"git produced output while failing", | ||
result.output, | ||
) | ||
self.assertIn( | ||
"hblaugh", | ||
result.output, | ||
) | ||
|
||
def test_no_changes_made(self): | ||
self._test_no_changes_made( | ||
"pyproject.toml", | ||
|
@@ -33,22 +71,7 @@ def _test_no_changes_made(self, pyproject_path, invoke): | |
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
with open(pyproject_path, "w") as f: | ||
f.write("[tool.towncrier]\n" 'package = "foo"\n') | ||
os.mkdir("foo") | ||
with open("foo/__init__.py", "w") as f: | ||
f.write('__version__ = "1.2.3"\n') | ||
os.mkdir("foo/newsfragments") | ||
fragment_path = "foo/newsfragments/123.feature" | ||
with open(fragment_path, "w") as f: | ||
f.write("Adds levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
call(["git", "checkout", "-b", "otherbranch"]) | ||
create_project(pyproject_path) | ||
|
||
result = invoke(runner, _main, ["--compare-with", "master"]) | ||
|
||
|
@@ -61,22 +84,7 @@ def test_fragment_exists(self): | |
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
with open("pyproject.toml", "w") as f: | ||
f.write("[tool.towncrier]\n" 'package = "foo"\n') | ||
os.mkdir("foo") | ||
with open("foo/__init__.py", "w") as f: | ||
f.write('__version__ = "1.2.3"\n') | ||
os.mkdir("foo/newsfragments") | ||
fragment_path = "foo/newsfragments/123.feature" | ||
with open(fragment_path, "w") as f: | ||
f.write("Adds levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
call(["git", "checkout", "-b", "otherbranch"]) | ||
create_project("pyproject.toml") | ||
|
||
file_path = "foo/somefile.py" | ||
with open(file_path, "w") as f: | ||
|
@@ -110,22 +118,7 @@ def test_fragment_missing(self): | |
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
with open("pyproject.toml", "w") as f: | ||
f.write("[tool.towncrier]\n" 'package = "foo"\n') | ||
os.mkdir("foo") | ||
with open("foo/__init__.py", "w") as f: | ||
f.write('__version__ = "1.2.3"\n') | ||
os.mkdir("foo/newsfragments") | ||
fragment_path = "foo/newsfragments/123.feature" | ||
with open(fragment_path, "w") as f: | ||
f.write("Adds levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
call(["git", "checkout", "-b", "otherbranch"]) | ||
create_project("pyproject.toml") | ||
|
||
file_path = "foo/somefile.py" | ||
with open(file_path, "w") as f: | ||
|