Skip to content

Commit

Permalink
feat: can choose initial branch and default initial branch tested is …
Browse files Browse the repository at this point in the history
…`main`
  • Loading branch information
esciara committed Oct 20, 2021
1 parent be38c77 commit 6433af2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
18 changes: 17 additions & 1 deletion behave4git/git_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,25 @@ def step_an_empty_git_repo(context):
command_util.ensure_context_attribute_exists(context, "repo", repo)


@given('an empty git repo with "{initial_branch}" as initial branch')
def step_an_empty_git_repo_with_initial_branch(context, initial_branch):
step_a_new_working_directory(context)
repo = Repo.init(context.workdir, initial_branch=initial_branch)
command_util.ensure_context_attribute_exists(context, "repo", repo)


@given("a starting git repo")
def step_a_starting_git_repo(context):
step_an_empty_git_repo(context)
step_an_empty_git_repo_with_initial_branch(context, "main")
context.surrogate_text = "foo bar"
step_a_file_named_filename_with(context, "initial_commit_file")
step_add_file_to_index(context, "initial_commit_file")
step_commit_index_with_message(context, "chore: initial commit")


@given('a starting git repo with "{initial_branch}" as initial branch')
def step_a_starting_git_repo_with_initial_branch(context, initial_branch):
step_an_empty_git_repo_with_initial_branch(context, initial_branch)
context.surrogate_text = "foo bar"
step_a_file_named_filename_with(context, "initial_commit_file")
step_add_file_to_index(context, "initial_commit_file")
Expand Down
4 changes: 2 additions & 2 deletions features/branch_steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Git steps reused throughout the features
Given a starting git repo
And I create the branch "my_branch"
Then the branch "my_branch" should exist
And the branch "my_branch" should be at the same level as branch "master"
And the branch "my_branch" should be at the same level as branch "main"

Scenario: Switch to a branch
Given a starting git repo
Expand All @@ -22,5 +22,5 @@ Feature: Git steps reused throughout the features
"""
And I add the file "branch_file" to the git index
And I commit the git index with message "chore: branch commit"
Then there should be 1 commit between head and the branch "master"
Then there should be 1 commit between head and the branch "main"
Then there should be 2 commit in "my_branch"
9 changes: 9 additions & 0 deletions features/initialise_repo_steps.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Git initialisation steps

Scenario: Initialise repo with initial branch named "main"
Given a starting git repo with "main" as initial branch
Then the branch "main" should exist

Scenario: Initialise repo with initial branch named "master"
Given a starting git repo with "master" as initial branch
Then the branch "master" should exist

0 comments on commit 6433af2

Please sign in to comment.