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

abacaba #304

Open
wants to merge 127 commits into
base: 0.4-i18n
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
dc57905
Merge pull request #178 from liliakai/patch-1
Gazler Dec 21, 2014
39eda89
Fix typo that prevented ".hidden" to be commited
snahor Jan 9, 2015
85ea0a2
Merge pull request #180 from snahor/patch-1
Gazler Jan 10, 2015
7e1dcd7
Added a basic submodule level
Jan 14, 2015
ab0a969
Merge pull request #183 from jackmaney/master
Gazler Jan 14, 2015
3d844f5
fix(fetch): ensure fetch level works on Windows
Feb 10, 2015
97fc248
fix(push_branch): ensure push_branch level works on Windows
Feb 10, 2015
cdc24b9
fix(reorder): ensure file3 is closed in merge_squash level
Feb 13, 2015
48bc5d3
flesh out game instructions in README
kytrinyx Dec 19, 2015
11ff6ba
Merge pull request #191 from kytrinyx/instructions
Gazler Dec 20, 2015
b21ce09
fix for the revert level 51
agargiulo Oct 4, 2015
923114c
give the detailed information about squash (squash which commits to w…
legendtkl Jan 1, 2016
1f8e3a5
Merge pull request #195 from legendtkl/master
Gazler Jan 1, 2016
dfc9b76
Merge pull request #194 from Gazler/fix/revert-level
Gazler Jan 1, 2016
84d101e
fix(levels/remote_url): allow a trailing slash on repo url
Gazler Jan 1, 2016
4958058
chore(version): bump to 0.4.5
Gazler Jan 1, 2016
49ffc88
add homepage
hooopo Jan 3, 2016
e227336
Merge pull request #197 from hooopo/add_homepage
Gazler Jan 3, 2016
fea1b1b
Fix typo: it's GitHub, not Github.
Jan 7, 2016
db16542
Merge pull request #200 from odegroot/fix-typo
Gazler Jan 7, 2016
798f838
fix(checkout_tag): only show commit message in solution
Gazler Jan 8, 2016
0c09f4c
chore(version): bump to 0.4.6
Gazler Jan 8, 2016
44289d2
fix(checkout_tag_over_branch): only show commit message in solution
Gazler Jan 11, 2016
ec4a8e4
chore(version): bump to 0.4.7
Gazler Jan 14, 2016
8869b25
fix(push): specify the files to copy
Gazler Jan 21, 2016
8f79c63
chore(version): bump to 0.4.8
Gazler Jan 21, 2016
af332ce
Update "githug reset" to allow numbers (#215)
zhanglintc Aug 4, 2016
8931d2f
fix(ignore): clarify level requirements (#216)
pallxk Aug 6, 2016
d8a3995
chore(gemspec): specify required rake version (#217)
pallxk Aug 10, 2016
1189d35
Clarify Description Wording
seanoldham Aug 17, 2016
5ce73ae
Merge pull request #218 from seanosaur/patch-1
Gazler Sep 30, 2016
fd38c65
fix(ProfileSpec): typo in profile test (#220)
vra Sep 30, 2016
c543aef
feat(rebase_onto): add level (#221)
janis-vitols Nov 13, 2016
109597c
chore(version): bump to 0.5.0
Gazler Nov 13, 2016
0cc1851
docs(README.md): fix typo stacktrace -> stack trace (#224)
guyskk Dec 3, 2016
f184f34
chore(.gemspec): remove commented out dependency (#222)
compwron Dec 3, 2016
1225f66
fix(submodule): fix minor typo (#226)
EdJoPaTo Jan 19, 2017
f91d505
docs(README.md): use svg badges (#230)
sobolevn Apr 6, 2017
392c357
feat(rm): print the hint on multiple lines (#231)
michaelkebe Apr 6, 2017
c92e35d
fix(Githug): stdout buffer problem (#227) (#228)
cocobear Apr 6, 2017
d763aa9
First level hint improvement (#233)
ysv Jul 25, 2017
2544b01
revised the language of the prompt for push level (#236)
elstamey Nov 2, 2017
d1de80a
Imporoved the hint of the test grep (#240)
tkhamis Jul 11, 2018
f54aa25
#45: merge_squash => #47: merge_squash (#246)
zhanglintc Dec 10, 2018
6b4c41d
fix(number_of_files_commit): ask for files not changes (#247)
duianto Feb 11, 2019
09f95a0
chore(fetch): remove trailing whitespace (#250)
duianto Feb 14, 2019
f7f17b2
Adding strip for string (#254)
vikrant-pune Apr 12, 2019
28775b4
Fix various typos. Remove double blanks. Rewrite find_old_branch (#257)
BreakBB Apr 26, 2019
d701a11
Clarify that reset task can be used to select a specific level in sho…
jackaponte Jun 15, 2019
2db7ee6
Fix git help command in hint (#263)
osartun Sep 3, 2019
69b6a78
Listing the levels, it show the solved levels in green and the pendin…
VictorMNA Oct 1, 2019
e6c3f8d
Make hint more helpful (lvl 20) (#267)
JHurdle91 Nov 11, 2019
a387bb3
Suggestion for level_8 Description (#274)
mayurilahane Jun 8, 2020
a760da2
Fix rename_commit level solution (#276)
gchazot Sep 17, 2020
95ab0a8
Updating hint message (#285)
dgaikwad Nov 10, 2020
c8cdaef
Added more clear hint (#283)
Ajoe-T Nov 10, 2020
f36bdf3
Checkout file from branch (#287)
connernilsen Dec 22, 2020
e71c4c1
Revert "Checkout file from branch (#287)"
stdtom Jul 26, 2021
c7a3e02
Revert "Listing the levels, it show the solved levels in green and th…
stdtom Jul 26, 2021
f830b1b
Removing old Ruby versions (1.8.7 and 1.9.2) from CI
stdtom Jul 26, 2021
a251d1b
Lift CI on new versions
stdtom Jul 26, 2021
13f9f1f
Remove Ruby versions unsupported on Ubuntu 20.04
stdtom Jul 26, 2021
9a739d3
Remove locking of RubyGems to version 2.1.11
stdtom Jul 26, 2021
a712bd5
Merge pull request #292 from stdtom/ci-new-versions
Gazler Jul 27, 2021
90f741b
Classroom concept, issue #313 (#314)
odiraneyya Mar 16, 2022
c3bc5a1
Added gitconfig to deliverables and removed level-folder volume (#317)
odiraneyya Mar 21, 2022
b78c39d
added FAQ to fix main and master branch name issue (#342)
aargeee Oct 13, 2023
90574f4
Added fix for 'main doesn't work' issue
Stowaway4331 Nov 1, 2023
411171d
fix(include.rb): correct hint to man page (#347)
nbehrnd Mar 18, 2024
62edc36
fix(commit.rb): explicitly define branch as master
nbehrnd Apr 8, 2024
dc3ba9a
style(config.rb): edit description of task ahead
nbehrnd Apr 17, 2024
949bb9e
fix(add.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
5278bbc
style(clone_to_folder): edit description of the task ahead
nbehrnd Apr 17, 2024
38f8c19
fix(ignore.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
9cc53a8
fix(include.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
0ef4151
fix(status.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
26ce22c
fix(number_of_files_committed): explicitly use master branch
nbehrnd Apr 17, 2024
f7764b5
fix(rm.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
8b8da75
fix(rm_cached.rb): explicitly defbe branch as master
nbehrnd Apr 17, 2024
e06a1a5
fix(stash.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
95a6041
fix(rename.rb): explicitly define branch as master
nbehrnd Apr 17, 2024
7d4cdaf
fix(restructure.rb): explicitly use master branch
nbehrnd Apr 17, 2024
1852203
fix(log.rb): explicitly use master branch
nbehrnd Apr 17, 2024
e713bbf
fix(tag.rb): explicitly use master branch
nbehrnd Apr 17, 2024
665d912
fix(push_tags.rb): explicitly use master branch
nbehrnd Apr 17, 2024
ef73a39
fix(commit_amend.rb): explicitly use master branch
nbehrnd Apr 17, 2024
d6c9656
fix(commit_in_future.rb): explicitly use master branch
nbehrnd Apr 17, 2024
aca9f70
fix(reset.rb): explicitly use master branch
nbehrnd Apr 17, 2024
158e6e6
fix(reset_soft.rb): explicitly use master branch
nbehrnd Apr 17, 2024
b7648b8
fix(checkout_file.rb): explicitly use master branch
nbehrnd Apr 17, 2024
c44ebdd
fix(remote.rb): explicitly use master branch
nbehrnd Apr 17, 2024
285fdb9
fix(remote_url.rb): explicitly use master branch
nbehrnd Apr 17, 2024
321c67e
fix(pull.rb): explicitly run branch master
nbehrnd Apr 17, 2024
8fe0c5e
fix(remote_add.rb): explicitly use branch master
nbehrnd Apr 17, 2024
593e972
fix(push.rb): explicitly run branch master
nbehrnd Apr 18, 2024
400359f
fix(diff.rb): explicitly use branch master
nbehrnd Apr 18, 2024
7efd605
fix(blame.rb): explicitly use branch master
nbehrnd Apr 18, 2024
605c2e1
fix(branch.rb): explicitly use branch master
nbehrnd Apr 18, 2024
2f0141b
fix(checkout.rb): explicitly use branch master
nbehrnd Apr 18, 2024
1ebef48
fix(checkout_tag.rb): explicitly use branch master
nbehrnd Apr 21, 2024
1183c19
fix(checkout_tag_over_branch.rb): explicitly use branch master
nbehrnd Apr 21, 2024
1c73673
fix(branch_at.rb): explicitly run branch master
nbehrnd Apr 21, 2024
e1172dd
fix(delete_branch.rb): explicitly run branch master
nbehrnd Apr 21, 2024
1d34349
fix(push_branch.rb): explicitly run branch master
nbehrnd Apr 21, 2024
13dfbf7
fix(merge.rb): explicitly run branch master
nbehrnd Apr 21, 2024
cd36f76
fix(fetch.rb): explicitly run branch master
nbehrnd Apr 21, 2024
59fc038
fix(rebase.rb): explicitly run branch master
nbehrnd Apr 21, 2024
347174c
fix(rebase_onto.rb): explicitly run branch master
nbehrnd Apr 21, 2024
9df68f0
fix(repack.rb): explicitly run branch master
nbehrnd Apr 21, 2024
acf3611
fix(cherry-pick.rb): explicitly run branch master
nbehrnd Apr 21, 2024
9c6e46f
fix(grep.rb): explicitly run branch master
nbehrnd Apr 21, 2024
c932283
fix(rename_commit.rb): explicitly run branch master
nbehrnd Apr 21, 2024
9958594
fix(squash.rb): explicitly run branch master
nbehrnd Apr 21, 2024
6eb67dc
fix(merge_squash.rb): explicitly run branch master
nbehrnd Apr 21, 2024
b576c5b
fix(reorder.rb): explicitly run branch master
nbehrnd Apr 21, 2024
275c6ad
fix(bisect.rb): explicitly run branch master
nbehrnd Apr 21, 2024
8a15a16
fix(stage_lines.rb): explicitly run branch master
nbehrnd Apr 21, 2024
eb7c007
fix(find_old_branch.rb): explicitly run branch master
nbehrnd Apr 21, 2024
09fbafd
fix(revert.rb): explicitly run branch master
nbehrnd Apr 21, 2024
9b9a0a3
fix(restore.rb): explicitly run branch master
nbehrnd Apr 21, 2024
675fac2
fix(conflict.rb): explicitly run branch master
nbehrnd Apr 21, 2024
33fcbc5
fix(submodule.rb): explicitly run branch master
nbehrnd Apr 21, 2024
dcbe5d3
style(rm.rb): edit internal task description
nbehrnd Apr 21, 2024
1266b29
style(push_tags.rb): edit internal task description
nbehrnd Apr 21, 2024
8229a4c
Merge pull request #348 from nbehrnd/branch_name
Gazler May 17, 2024
c420f62
Merge pull request #344 from Stowaway4331/stow4331-mods
Gazler Aug 5, 2024
a613718
release: 0.5.1
Gazler Aug 11, 2024
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
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
language: ruby

dist: focal
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1
- 2.4.10
- 2.5.9
- 2.6.8
- 2.7.4
- 3.0.1
- ruby-head

matrix:
allow_failures:
- rvm: ruby-head

before_install:
- gem update --system 2.1.11
- gem update --system
- git config --global user.email 'user@example.com'
- git config --global user.name 'Test User'
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM ruby:slim

LABEL org.opencontainers.image.authors="diraneyya@ip.rwth-aachen.de"

# This is in order to have the man pages during exercises
RUN sed -i '/path-exclude \/usr\/share\/man/d' /etc/dpkg/dpkg.cfg.d/docker
RUN sed -i '/path-exclude \/usr\/share\/groff/d' /etc/dpkg/dpkg.cfg.d/docker
RUN apt update && apt install -y man git && apt install --reinstall coreutils

# The DATA_PATH is used for the deliverables, or the submissible
# content for the classroom activity.
ENV DATA_PATH="/data"
# The REPO_PATH is where the original or the teacher's forked repo
# resides inside the container.
ENV REPO_PATH="/root/githug"
# The LEVEL_PATH is where the current challenge resides and where
# students should navigate prior to attemping to use the `githug`
# commands.
ENV LEVEL_PATH="/git_hug"
ENV GITHUG_GITCONF="/root/.gitconfig"
ENV GITHUG_PROFILE="$LEVEL_PATH/.profile.yml"
ENV GITHUG_HISTORY_OUTPUT="$DATA_PATH/history.txt"
ENV GITHUG_PROFILE_OUTPUT="$DATA_PATH/profile.yml"
ENV GITHUG_GITCONF_OUTPUT="$DATA_PATH/gitconfig"

RUN mkdir -p $DATA_PATH
ADD . $REPO_PATH
WORKDIR $REPO_PATH
RUN gem build
RUN gem install *.gem

WORKDIR /
RUN echo "y" | $GEM_HOME/bin/githug
RUN cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT

WORKDIR $LEVEL_PATH

# The bash login script in below clears the history and restores
# progress using the contents of the $GITHUG_PROFILE_OUTPUT file.
RUN printf "history -c\nHISTSIZE= \nHISTFILESIZE= \n\
echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT \n\
if ! [ -e $GITHUG_PROFILE_OUTPUT ]; then \n\
echo 'ERROR: Corrupt level progress data. Exiting.' \n\
echo '>>> CORRUPT DATA <<<' >> $GITHUG_HISTORY_OUTPUT \n\
exit 1; fi \n\
cp $GITHUG_GITCONF_OUTPUT $GITHUG_GITCONF \n\
mkdir -p $LEVEL_PATH && cp $GITHUG_PROFILE_OUTPUT $GITHUG_PROFILE \n\
export PATH=\"\$GEM_HOME/bin:\$PATH\" \n\
cd $LEVEL_PATH && githug reset \n\
echo -e '\nIMPORTANT: everything you type in this container is \
recorded to assist in the grading process.' \n" >> ~/.bash_profile

RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT \n\
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n\
cp $GITHUG_GITCONF $GITHUG_GITCONF_OUTPUT 2>/dev/null \n\
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n" >> ~/.bash_logout

ENTRYPOINT ["/bin/bash", "--login"]
VOLUME $DATA_PATH
86 changes: 78 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,67 @@
# Githug
Git Your Game On [![Build Status](https://travis-ci.org/Gazler/githug.png?branch=master)](https://travis-ci.org/Gazler/githug) [![Code Climate](https://codeclimate.com/github/Gazler/githug.png)](https://codeclimate.com/github/Gazler/githug)
Git Your Game On

[![Build Status](https://travis-ci.org/Gazler/githug.svg?branch=master)](https://travis-ci.org/Gazler/githug) [![Code Climate](https://codeclimate.com/github/Gazler/githug.svg)](https://codeclimate.com/github/Gazler/githug)

## About
Githug is designed to give you a practical way of learning git. It has a series of levels, each requiring you to use git commands to arrive at a correct answer.

## Installation
## Playing Githug

Githug should work on Linux, OS X and Windows.

### Prerequisites

Githug requires Ruby 1.8.7 or higher.

You can check which version of Ruby is installed with the following command:

```
ruby --version
```

If ruby is not installed, follow the installation instructions on [ruby-lang.org](https://www.ruby-lang.org/en/documentation/installation/).

### Installation

To install Githug, run

gem install githug

After the gem is installed, run `githug`. You will be prompted to create a directory. Githug should work on Linux, OS X and Windows.
If you get a complaint about permissions, you can rerun the command with `sudo`:

sudo gem install githug

#### Usage with Docker

An unofficial _Docker_ image for this project by [@odiraneyya](https://github.com/odiraneyya) is available on ([Docker Hub](https://hub.docker.com/r/orwa84/githug)).

### Starting the Game

After the gem is installed change directory to the location where you want the game-related assets to be stored.
Then run `githug`:

githug

## Commands
You will be prompted to create a directory.

Githug has 5 commands:
No githug directory found, do you wish to create one? [yn]

Type `y` (yes) to continue, `n` (no) to cancel and quit Githug.

### Commands

Githug has 4 game commands:

* play - The default command, checks your solution for the current level
* hint - Gives you a hint (if available) for the current level
* reset - Reset the current level or reset the level to a given name or path
* levels - List all the levels
* test - Test levels in development (please see the "Testing Levels" section below)

## Change Log

The change log is available on the wiki. [Change log](https://github.com/Gazler/githug/wiki/Change-Log)


## Contributing

To suggest a level or create a level that has been suggested, check out [the wiki](https://github.com/Gazler/githug/wiki).
Expand Down Expand Up @@ -112,6 +149,39 @@ The easiest way to test a level is:
* Solve the level
* Run `githug test PATH_TO_YOUR_LEVEL`

Please note that the `githug test` command can be run as `githug test --errors` to get an error stacktrace from your solve method.
Please note that the `githug test` command can be run as `githug test --errors` to get an error stack trace from your solve method.

It would be ideal if you add an integration test for your level. These tests live in `spec/githug_spec` and **must** be run in order. If you add a level but do not add a test, please add a simple `skip_level` test case similar to the `contribute` level.

## FAQs

1. Answers are not being checked properly

*This is a common issue we are facing and we are actively working to fix it.*

For now, run the following commands to change the default branch name to master. This should fix most of the issues you may face.
```
$ git config --global init.defaultBranch master
$ githug reset
```

From the current level forward, the default branch will be `master`.

2. `githug` command doesn't work

Githug currently isn't supported on ruby versions ^3.0.0. Use any ruby version below 3.0.0 (preferrably 2.7.1).

If you use rvm, execute the below commands

```
$ rvm install 2.7.1
$ rvm use 2.7.1
```

If you use rbenv, execute the below commands

```
$ rbenv install 2.7.1
$ rbenv global 2.7.1
```

7 changes: 3 additions & 4 deletions githug.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Gem::Specification.new do |s|
s.name = "githug"
s.version = Githug::VERSION
s.authors = ["Gary Rennie"]
s.email = ["webmaster@gazler.com"]
s.homepage = ""
s.email = ["gazler@gmail.com"]
s.homepage = "https://github.com/Gazler/githug"
s.summary = %q{An interactive way to learn git.}
s.description = %q{An interactive way to learn git.}

Expand All @@ -23,6 +23,5 @@ Gem::Specification.new do |s|

s.add_dependency "grit", "~>2.3.0"
s.add_dependency "thor", "~>0.14.6"
s.add_dependency "rake"
# s.add_runtime_dependency "rest-client"
s.add_dependency "rake", "<11"
end
5 changes: 3 additions & 2 deletions levels/add.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
difficulty 1
description "There is a file in your folder called `README`, you should add it to your staging area
Note: You start each level with a new repo. Don't look for files from the previous one."
description "There is a file in your folder called `README`; add it to your staging area.
Note: Each level starts with a new repo. Don't look for files of the previous one."

setup do
repo.init
FileUtils.touch("README")
system "git branch -m master"
end

solution do
Expand Down
3 changes: 2 additions & 1 deletion levels/bisect.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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 (the abbreviated hash) that introduced the bug?"

setup do
init_from_level
repo.init
system "git branch -m master"
end

solution do
Expand Down
5 changes: 3 additions & 2 deletions levels/blame.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
difficulty 2
description "Someone has put a password inside the file `config.rb` find out who it was."
description "Identify who put a password inside the file `config.rb`."

setup do
init_from_level
system "git branch -m master"
end

solution do
offender = repo.commit("97bdd0cccf9f4b8730f78cb53a81a74f205dbcc2").author.name
request("Who made the commit with the password?").downcase == offender.downcase
request("Who made the commit with the password?").downcase.strip == offender.downcase
end

hint do
Expand Down
3 changes: 2 additions & 1 deletion levels/branch.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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 "To work on a piece of code that has the potential to break things, create the branch test_code."

setup do
repo.init
FileUtils.touch("README")
repo.add "README"
repo.commit_all("Initial commit")
system "git branch -m master"
end

solution do
Expand Down
5 changes: 3 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 @@ -12,11 +12,12 @@
File.open("file1", 'a') { |f| f.write("\nAdding some more text") }
repo.add("file1")
repo.commit_all("Updating file1 again")
system "git branch -m master"
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" }
repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" }
true
end

Expand Down
3 changes: 2 additions & 1 deletion levels/checkout.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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
FileUtils.touch("README")
repo.add("README")
repo.commit_all("initial commit")
system "git branch -m master"
end

solution do
Expand Down
3 changes: 2 additions & 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 All @@ -14,6 +14,7 @@
File.open("config.rb", "a") do |file|
file.puts("These are changed you don't want to keep!")
end
system "git branch -m master"
end

solution do
Expand Down
4 changes: 3 additions & 1 deletion levels/checkout_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
repo.add("app.rb")
repo.commit_all("Changes galore")
repo.git.tag( { 'f' => true }, "v1.5" )

system "git branch -m master"
end

solution do
return false unless repo.commits.length == 5
return false unless `git show HEAD` =~ /Some more changes/
return false unless `git show HEAD --format=%s` =~ /Some more changes/
true
end

Expand Down
3 changes: 2 additions & 1 deletion levels/checkout_tag_over_branch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
FileUtils.touch("app.rb")
repo.add("app.rb")
repo.commit_all("Initial commit")
system "git branch -m master"

`echo "Some code" >> app.rb`
repo.add("app.rb")
Expand Down Expand Up @@ -37,7 +38,7 @@

solution do
return false unless repo.commits.length == 5
return false unless `git show HEAD` =~ /Some more changes/
return false unless `git show HEAD --format=%s` =~ /Some more changes/
true
end

Expand Down
7 changes: 4 additions & 3 deletions levels/cherry-pick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
description "Your new feature isn't worth the time and you're going to delete it. But it has one commit that fills in `README` file, and you want this commit to be on the master as well."

setup do
init_from_level
`git stash` #fix for README.md being in githug root an the level
init_from_level
`git stash` # fix for README.md being in githug root an the level
system "git branch -m master"
end

solution do
Expand All @@ -13,5 +14,5 @@
end

hint do
puts "Sneak a peek at the `cherry-pick` command."
puts "Sneak a peek at the `git help cherry-pick` command."
end
2 changes: 1 addition & 1 deletion levels/clone_to_folder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 into the folder `my_cloned_repo`."

solution do
repo("my_cloned_repo").commit("157b2b61f29ab9df45f31c7cd9cb5d8ff06ecde4")
Expand Down
1 change: 1 addition & 0 deletions levels/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

setup do
repo.init
system "git branch -m master"
FileUtils.touch("README")
repo.add("README")
end
Expand Down
Loading