Skip to content

Commit

Permalink
Default to HEAD if --branch is not given (#43)
Browse files Browse the repository at this point in the history
* Default to HEAD if --branch is not given

* Adapt test cases for command-line interface
  • Loading branch information
cjolowicz committed Jun 5, 2020
1 parent c0b01dc commit c95ebfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/retrocookie/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def main(
create_branch = branch

if not commits and branch is None:
raise click.UsageError("either commits or --branch must be specified")
commits = ["HEAD"]

path = Path(directory) if directory else None
retrocookie(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def mock_retrocookie(monkeypatch: MonkeyPatch) -> None:
["--help"],
["/home/user/src/repo", "--branch=topic"],
["--branch=topic", "/home/user/src/repo"],
["--branch=topic", "/home/user/src/repo", "HEAD"],
["--branch=topic", "/home/user/src/repo", "18240dd"],
["--branch=topic", "https://example.com/owner/repo.git"],
["--branch=topic", "--create", "repo"],
["--branch=topic", "--create-branch=other", "repo"],
Expand All @@ -43,8 +43,9 @@ def mock_retrocookie(monkeypatch: MonkeyPatch) -> None:
"repo",
],
["--branch=topic", "--blacklist=github_user", "repo"],
["/home/user/src/repo", "HEAD"],
["/home/user/src/repo", "HEAD", "--create-branch=topic"],
["/home/user/src/repo"],
["/home/user/src/repo", "18240dd"],
["/home/user/src/repo", "--create-branch=topic"],
],
)
def test_usage_success(
Expand All @@ -59,8 +60,7 @@ def test_usage_success(
"args",
[
[],
["repo"],
["--create", "repo", "HEAD"],
["--create", "repo"],
["--branch=topic"],
["--branch=topic", "--create", "--create-branch=another", "repo"],
],
Expand Down

0 comments on commit c95ebfa

Please sign in to comment.