Skip to content

Commit

Permalink
Fix various typos. Remove double blanks. Rewrite find_old_branch (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
BreakBB authored and Gazler committed Apr 26, 2019
1 parent f7f17b2 commit 28775b4
Show file tree
Hide file tree
Showing 28 changed files with 52 additions and 54 deletions.
2 changes: 1 addition & 1 deletion levels/bisect.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 3
description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit that introduced the bug."
description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit that introduced the bug."

setup do
init_from_level
Expand Down
4 changes: 2 additions & 2 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 the branch test_branch at the commit before the last."

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

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" }
repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" }
true
end

Expand Down
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion levels/checkout_file.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
difficulty 3

description "A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit."
description "A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit."

setup do
repo.init
Expand Down
2 changes: 1 addition & 1 deletion levels/cherry-pick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup do
init_from_level
`git stash` #fix for README.md being in githug root an the level
`git stash` # fix for README.md being in githug root an the level
end

solution do
Expand Down
2 changes: 1 addition & 1 deletion levels/commit_amend.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it."
description "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it."

setup do
repo.init
Expand Down
2 changes: 1 addition & 1 deletion levels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
end

hint do
puts "These settings are config settings. You should run `git help config` if you are stuck."
puts "These settings are config settings. You should run `git help config` if you are stuck."
end
2 changes: 1 addition & 1 deletion levels/contribute.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 3
description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation."
description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation."

solution do
location = "/tmp/githug"
Expand Down
4 changes: 2 additions & 2 deletions levels/diff.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "There have been modifications to the `app.rb` file since your last commit. Find out which line has changed."
description "There have been modifications to the `app.rb` file since your last commit. Find out which line has changed."

setup do
init_from_level
Expand All @@ -12,5 +12,5 @@
end

hint do
puts "You are looking for the difference since your last commit. Don't forget that running `git` on its own will list the possible commands."
puts "You are looking for the difference since your last commit. Don't forget that running `git` on its own will list the possible commands."
end
9 changes: 4 additions & 5 deletions levels/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# local repo
repo.init

#adds a file to origin/master
# adds a file to origin/master
FileUtils.touch "master_file"
repo.add "master_file"
repo.commit_all 'Commits master_file'
Expand All @@ -19,12 +19,12 @@
Dir.chdir tmpdir
repo.init

#adds a file to origin/master
# adds a file to origin/master
FileUtils.touch "master_file"
repo.add "master_file"
repo.commit_all 'Commits master_file'

#adds remote repo
# adds remote repo
Dir.chdir cwd
`git remote add origin #{tmpdir}/.git`
`git fetch origin --quiet`
Expand All @@ -45,13 +45,12 @@
repo.init
result = true


# counts the number of local branches. Should equal 1
local_branches = repo.branches.size

# after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line
# This command will count the number of lines, which will give the number of branches
if File.file?('.git/FETCH_HEAD') #checks for file existance
if File.file?('.git/FETCH_HEAD') # checks for file existence
num_remote = File.read(".git/FETCH_HEAD").split("\n").count
else
num_remote = 0
Expand Down
2 changes: 1 addition & 1 deletion levels/find_old_branch.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 4
description "You have been working on a branch but got distracted by a major issue and forgot the name of it. Switch back to that branch."
description "You have been working on a branch but got distracted by a major issue. Switch back to that branch even though you forgot the name of it."

setup do
init_from_level
Expand Down
2 changes: 1 addition & 1 deletion levels/ignore.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore those swap files which are ending in `.swp`."
description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore those swap files which are ending in `.swp`."

setup do
repo.init
Expand Down
2 changes: 1 addition & 1 deletion levels/include.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file."
description "Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file."

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

description "You will be asked for the hash of most recent commit. You will need to investigate the logs of the repository for this."
description "Find out what the hash of the latest commit is."

setup do
repo.init
Expand All @@ -14,5 +14,5 @@
end

hint do
puts "You need to investigate the logs. There is probably a command for doing that!"
puts "You need to investigate the logs. There is probably a command for doing that!"
end
12 changes: 6 additions & 6 deletions levels/number_of_files_committed.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
difficulty 1
description "There are some files in this repository, how many of the files will be committed?"
description "There are some files in this repository, how many of the files are staged for a commit?"

setup do
repo.init

#Modified files
# Modified files
%w{rubyfile4.rb rubyfile5.rb}.each do |file|
FileUtils.touch(file)
repo.add(file)
end
repo.commit_all "Commit"

#Staged file
# Staged file
File.open("rubyfile4.rb", 'w') { |f| f << "#Changes" }
repo.add("rubyfile4.rb")

#Not staged file
# Not staged file
File.open("rubyfile5.rb", 'w') { |f| f << "#Changes" }

#Changes to be committed
# Changes to be committed
%w{rubyfile1.rb}.each do |file|
FileUtils.touch(file)
repo.add(file)
end

#Untrached files
# Untracked files
%w{rubyfile6.rb rubyfile7.rb}.each do |file|
FileUtils.touch(file)
end
Expand Down
22 changes: 11 additions & 11 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 @@ -18,12 +18,12 @@
# copy the repo to remote
FileUtils.cp_r ".", tmpdir

# add another file. If successful this file won't be pushed to the remote repository
# add another file. If successful this file won't be pushed to the remote repository
FileUtils.touch "file2"
repo.add "file2"
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
# This branch should not be pushed to to the remote repository
`git checkout -b other_branch --quiet`
# add another file
FileUtils.touch "file3"
Expand All @@ -32,7 +32,7 @@

`git checkout -b test_branch --quiet`

#This file should get pushed if the level is successful
# This file should get pushed if the level is successful
FileUtils.touch "file4"
repo.add "file4"
repo.commit_all "committed change on test_branch"
Expand All @@ -51,30 +51,30 @@
`git fetch --quiet origin`
`git branch -u origin/master master 2> /dev/null`

`git checkout master --quiet` #return to master branch
`git checkout master --quiet` # return to master branch
end

solution do
repo.init
result = false

#each branch consits of one line, `wc -l counts the number of lines in order to get the number of remote branches`
#At the moment Grit doesn't support remote branch references but is on the ToDo list. This should be revisited when Grit implements the change
# each branch consists of one line, `wc -l` counts the number of lines in order to get the number of remote branches
# At the moment Grit doesn't support remote branch references but is on the ToDo list. This should be revisited when Grit implements the change
num_remote_branches = `git branch -r`.split("\n").count

# 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 and only 2 remote branches exists
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
# 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! ***"

#User pushed up the master banch, level failed
# User pushed up the master branch, 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! ***"
end
Expand Down
4 changes: 2 additions & 2 deletions levels/remote.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
difficulty 2

description "This project has a remote repository. Identify it."
description "This project has a remote repository. Identify it."

setup do
repo.init
Expand All @@ -12,5 +12,5 @@
end

hint do
puts "You are looking for a remote. You can run `git` for a list of commands."
puts "You are looking for a remote. You can run `git` for a list of commands."
end
2 changes: 1 addition & 1 deletion levels/remote_url.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
Expand Down
2 changes: 1 addition & 1 deletion levels/reset.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 2
description "There are two files to be committed. The goal was to add each file as a separate commit, however both were added by accident. Unstage the file `to_commit_second.rb` using the reset command (don't commit anything)."
description "There are two files to be committed. The goal was to add each file as a separate commit, however both were added by accident. Unstage the file `to_commit_second.rb` using the reset command (don't commit anything)."

setup do
repo.init
Expand Down
4 changes: 2 additions & 2 deletions levels/restore.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 4
description "You decided to delete your latest commit by running `git reset --hard HEAD^`. (Not a smart thing to do.) You then change your mind, and want that commit back. Restore the deleted commit."
description "You decided to delete your latest commit by running `git reset --hard HEAD^` (not a smart thing to do). Now you changed your mind and want that commit back. Restore the deleted commit."

setup do
repo.init
Expand All @@ -24,5 +24,5 @@
end

hint do
puts "The commit is still floating around somewhere. Have you checked out `git reflog`?"
puts "The commit is still floating around somewhere. Have you checked out `git reflog`?"
end
2 changes: 1 addition & 1 deletion levels/restructure.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
difficulty 3

description "You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named `src` and using Git move all of the .html files into this folder."
description "You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named `src` and use Git move all of the .html files into this folder."

setup do
repo.init
Expand Down
3 changes: 1 addition & 2 deletions levels/revert.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
difficulty 4
description "You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history."
description "You have committed several times but want to undo the middle commit. All commits have been pushed, so you can't change existing history."

setup do
repo.init
Expand Down
2 changes: 1 addition & 1 deletion levels/rm.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
difficulty 2

description "A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it."
description "A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it."

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

description "A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git."
description "A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git."

setup do
repo.init
Expand All @@ -14,5 +14,5 @@
end

hint do
puts "You may need to use more than one command to complete this. You have checked your staging area in a previous level. Don't forget to run `git` for a list of commands."
puts "You may need to use more than one command to complete this. You have checked your staging area in a previous level. Don't forget to run `git` for a list of commands."
end
2 changes: 1 addition & 1 deletion levels/squash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
end

hint do
puts "Take a look the `-i` flag of the rebase command."
puts "Take a look at the `-i` flag of the rebase command."
end
2 changes: 1 addition & 1 deletion levels/stage_lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
end

hint do
puts "You might want to try to manipulate the hunks of the diff to choose which lines of the diff get staged. Read about the flags which can be passed to the `add` command; `man git-add`."
puts "You might want to try to manipulate the hunks of the diff to choose which lines of the diff get staged. Read about the flags which can be passed to the `add` command; `git --help add`."
end
2 changes: 1 addition & 1 deletion levels/stash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
end

hint do
puts "It's like stashing. Try finding appropriate git command."
puts "It's like stashing. Try finding an appropriate git command."
end
2 changes: 1 addition & 1 deletion levels/status.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 1
description "There are some files in this repository, one of the files is untracked, which file is it?"
description "There are some files in this repository, but only one of them is untracked. Which file is it?"

setup do
repo.init
Expand Down

0 comments on commit 28775b4

Please sign in to comment.