Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch tag repo underscore to dash #249

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions levels/branch.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 1
description "You want to work on a piece of code that has the potential to break things, create the branch test_code."
description "You want to work on a piece of code that has the potential to break things, create the branch test-code."

setup do
repo.init
Expand All @@ -9,7 +9,7 @@
end

solution do
repo.branches.map(&:name).include?("test_code")
repo.branches.map(&:name).include?("test-code")
end

hint do
Expand Down
6 changes: 3 additions & 3 deletions levels/branch_at.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 3
description "You forgot to branch at the previous commit and made a commit on top of it. Create branch test_branch at the commit before the last."
description "You forgot to branch at the previous commit and made a commit on top of it. Create branch test-branch at the commit before the last."

setup do
repo.init
Expand All @@ -15,8 +15,8 @@
end

solution do
return false unless repo.branches.map(&:name).include?("test_branch")
repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" }
return false unless repo.branches.map(&:name).include?("test-branch")
repo.commits("test-branch").each { |commit| return false if commit.message == "Updating file1 again" }
true
end

Expand Down
4 changes: 2 additions & 2 deletions levels/checkout.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "Create and switch to a new branch called my_branch. You will need to create a branch like you did in the previous level."
description "Create and switch to a new branch called my-branch. You will need to create a branch like you did in the previous level."

setup do
repo.init
Expand All @@ -9,7 +9,7 @@
end

solution do
return false unless repo.head.name == "my_branch"
return false unless repo.head.name == "my-branch"
true
end

Expand Down
4 changes: 2 additions & 2 deletions levels/clone_to_folder.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
difficulty 1
description "Clone the repository at https://github.com/Gazler/cloneme to `my_cloned_repo`."
description "Clone the repository at https://github.com/Gazler/cloneme to `my-cloned-repo`."

solution do
repo("my_cloned_repo").commit("157b2b61f29ab9df45f31c7cd9cb5d8ff06ecde4")
repo("my-cloned-repo").commit("157b2b61f29ab9df45f31c7cd9cb5d8ff06ecde4")
end

hint do
Expand Down
2 changes: 1 addition & 1 deletion levels/conflict.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 4
description "You need to merge mybranch into the current branch (master). But there may be some incorrect changes in mybranch which may cause conflicts. Solve any merge-conflicts you come across and finish the merge."
description "You need to merge my-branch into the current branch (master). But there may be some incorrect changes in my-branch which may cause conflicts. Solve any merge-conflicts you come across and finish the merge."

setup do
init_from_level
Expand Down
6 changes: 3 additions & 3 deletions levels/delete_branch.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
difficulty 2

description "You have created too many branches for your project. There is an old branch in your repo called 'delete_me', you should delete it."
description "You have created too many branches for your project. There is an old branch in your repo called 'delete-me', you should delete it."

setup do
init_from_level
end

solution do
return true unless repo.branches.map(&:name).include?('delete_me')
return true unless repo.branches.map(&:name).include?('delete-me')
end

hint do
puts "Running 'git --help branch' will give you a list of branch commands."
end
end
2 changes: 1 addition & 1 deletion levels/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

Dir.chdir tmpdir
# create a new branch in the remote repo
`git checkout -b new_branch --quiet`
`git checkout -b new-branch --quiet`

# adds a file into the new branch. Should not be pulled into the local
FileUtils.touch "file1"
Expand Down
2 changes: 1 addition & 1 deletion levels/find_old_branch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

solution do
return false unless repo.head.name == "solve_world_hunger"
return false unless repo.head.name == "solve-world-hunger"
true
end

Expand Down
16 changes: 8 additions & 8 deletions levels/push_branch.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "You've made some changes to a local branch and want to share it, but aren't yet ready to merge it with the 'master' branch. Push only 'test_branch' to the remote repository"
description "You've made some changes to a local branch and want to share it, but aren't yet ready to merge it with the 'master' branch. Push only 'test-branch' to the remote repository"

setup do

Expand All @@ -24,18 +24,18 @@
repo.commit_all "If this commit gets pushed to repo, then you have lost the level :( "

#This branch should not be pushed to to the remote repository
`git checkout -b other_branch --quiet`
`git checkout -b other-branch --quiet`
# add another file
FileUtils.touch "file3"
repo.add "file3"
repo.commit_all "If this commit gets pushed to repo, then you have lost the level :( "

`git checkout -b test_branch --quiet`
`git checkout -b test-branch --quiet`

#This file should get pushed if the level is successful
FileUtils.touch "file4"
repo.add "file4"
repo.commit_all "committed change on test_branch"
repo.commit_all "committed change on test-branch"

# remote repo
Dir.chdir tmpdir
Expand Down Expand Up @@ -64,19 +64,19 @@

# counts the number of commits in the remote master branch'
remote_master_commits = repo.commits('origin/master').count
remote_test_branch_commits = repo.commits('origin/test_branch').count #if returns 0 indicates that the remote test_branch doesn't exist
remote_test_branch_commits = repo.commits('origin/test-branch').count #if returns 0 indicates that the remote test-branch doesn't exist

#Level will be successful if the remote master branch remains at 1 commit, the remote test_branch exits and the number of remote branches
#Level will be successful if the remote master branch remains at 1 commit, the remote test-branch exits and the number of remote branches
if remote_master_commits == 1 and remote_test_branch_commits > 0 and num_remote_branches == 2
result = true

#User pushed up too many branches, level failed
elsif num_remote_branches > 2
puts "*** It looks like you pushed up too many branches. You need to make sure only 'test_branch' gets pushed. Please try again! ***"
puts "*** It looks like you pushed up too many branches. You need to make sure only 'test-branch' gets pushed. Please try again! ***"

#User pushed up the master banch, level failed
elsif remote_master_commits > 1
puts "*** It looks like you pushed up new master branch changes. You need to make sure only 'test_branch' gets pushed. Please try again! ***"
puts "*** It looks like you pushed up new master branch changes. You need to make sure only 'test-branch' gets pushed. Please try again! ***"
end

result
Expand Down
6 changes: 3 additions & 3 deletions levels/push_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
FileUtils.touch "file1"
repo.add "file1"
repo.commit_all "First commit"
repo.git.tag({'f' => true}, "tag_to_be_pushed")
repo.git.tag({'f' => true}, "tag-to-be-pushed")

FileUtils.touch "file2"
repo.add "file2"
Expand All @@ -35,7 +35,7 @@

# delete tags from remote
Dir.chdir tmpdir
repo.git.tag({'d' => true}, "tag_to_be_pushed")
repo.git.tag({'d' => true}, "tag-to-be-pushed")

# change back to local repo
Dir.chdir cwd
Expand All @@ -52,7 +52,7 @@

# see if we have the correct tag in the remote
remote_tags.each do |t|
solved=true if t.include?("refs/tags/tag_to_be_pushed")
solved=true if t.include?("refs/tags/tag-to-be-pushed")
end

solved
Expand Down
6 changes: 3 additions & 3 deletions levels/rebase_onto.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
difficulty 2

description "You have created your branch from `wrong_branch` and already made some commits, \
description "You have created your branch from `wrong-branch` and already made some commits, \
and you realise that you needed to create your branch from `master`. \
Rebase your commits onto `master` branch so that you don't have `wrong_branch` commits."
Rebase your commits onto `master` branch so that you don't have `wrong-branch` commits."

setup do
readme_file = "README.md"
Expand All @@ -14,7 +14,7 @@
repo.add(authors_file)
repo.commit_all("Create authors file")

repo.git.native :checkout, { "b" => true }, "wrong_branch"
repo.git.native :checkout, { "b" => true }, "wrong-branch"
File.open(authors_file, "w") { |f| f << "None\n" }
repo.add(authors_file)
repo.commit_all("Wrong changes")
Expand Down
4 changes: 2 additions & 2 deletions levels/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

setup do
repo.init
repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug")
repo.remote_add("my-remote-repo", "https://github.com/Gazler/githug")
end

solution do
"my_remote_repo" == request("What is the name of the remote repository?")
"my-remote-repo" == request("What is the name of the remote repository?")
end

hint do
Expand Down
6 changes: 3 additions & 3 deletions levels/remote_url.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
difficulty 2

description "The remote repositories have a url associated to them. Please enter the url of remote_location."
description "The remote repositories have a url associated to them. Please enter the url of remote-location."

setup do
repo.init
repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug")
repo.remote_add("remote_location", "https://github.com/githug/not_a_repo")
repo.remote_add("my-remote-repo", "https://github.com/Gazler/githug")
repo.remote_add("remote-location", "https://github.com/githug/not_a_repo")
end

solution do
Expand Down
4 changes: 2 additions & 2 deletions levels/tag.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
difficulty 2

description "We have a git repo and we want to tag the current commit with `new_tag`."
description "We have a git repo and we want to tag the current commit with `new-tag`."

setup do
repo.init
Expand All @@ -10,7 +10,7 @@
end

solution do
repo.tags.first.name == "new_tag"
repo.tags.first.name == "new-tag"
end

hint do
Expand Down
18 changes: 9 additions & 9 deletions spec/githug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def skip_level
end

it "solves the clone_to_folder level" do
`git clone https://github.com/Gazler/cloneme my_cloned_repo`
`git clone https://github.com/Gazler/cloneme my-cloned-repo`
`githug`.should be_solved
end

Expand Down Expand Up @@ -115,7 +115,7 @@ def skip_level
end

it "solves the tag level" do
`git tag new_tag`
`git tag new-tag`
`githug`.should be_solved
end

Expand Down Expand Up @@ -186,12 +186,12 @@ def skip_level
end

it "solves the branch level" do
`git branch test_code`
`git branch test-code`
`githug`.should be_solved
end

it "solves the checkout level" do
`git checkout -b my_branch`
`git checkout -b my-branch`
`githug`.should be_solved
end

Expand All @@ -207,17 +207,17 @@ def skip_level

it "solves the branch_at level" do
commit = `git log HEAD~1 --pretty=short | head -1 | cut -d " " -f 2`
`git branch test_branch #{commit}`
`git branch test-branch #{commit}`
`githug`.should be_solved
end

it "solves the delete_branch level" do
`git branch -d delete_me`
`git branch -d delete-me`
`githug`.should be_solved
end

it "solves the push_branch level" do
`git push origin test_branch`
`git push origin test-branch`
`githug`.should be_solved
end

Expand All @@ -239,7 +239,7 @@ def skip_level

it "solves the rebase_onto level" do
`git checkout readme-update`
`git rebase --onto master wrong_branch readme-update`
`git rebase --onto master wrong-branch readme-update`
`githug`.should be_solved
end

Expand Down Expand Up @@ -285,7 +285,7 @@ def skip_level
end

it "solves the find_old_branch level" do
`git checkout solve_world_hunger`
`git checkout solve-world-hunger`
`githug`.should be_solved
end

Expand Down