githug 0.4.8 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -7
- data/Dockerfile +59 -0
- data/README.md +42 -2
- data/githug.gemspec +2 -3
- data/levels/add.rb +3 -2
- data/levels/bisect.rb +2 -1
- data/levels/blame.rb +3 -2
- data/levels/branch.rb +2 -1
- data/levels/branch_at.rb +3 -2
- data/levels/checkout.rb +2 -1
- data/levels/checkout_file.rb +2 -1
- data/levels/checkout_tag.rb +2 -0
- data/levels/checkout_tag_over_branch.rb +1 -0
- data/levels/cherry-pick.rb +4 -3
- data/levels/clone_to_folder.rb +1 -1
- data/levels/commit.rb +1 -0
- data/levels/commit_amend.rb +2 -1
- data/levels/commit_in_future.rb +2 -1
- data/levels/config.rb +2 -2
- data/levels/conflict.rb +1 -0
- data/levels/contribute.rb +1 -1
- data/levels/delete_branch.rb +3 -2
- data/levels/diff.rb +3 -2
- data/levels/fetch.rb +13 -13
- data/levels/find_old_branch.rb +2 -1
- data/levels/grep.rb +1 -0
- data/levels/ignore.rb +2 -1
- data/levels/include.rb +3 -2
- data/levels/init.rb +1 -1
- data/levels/log.rb +3 -2
- data/levels/merge.rb +4 -3
- data/levels/merge_squash.rb +1 -0
- data/levels/number_of_files_committed.rb +10 -9
- data/levels/pull.rb +1 -0
- data/levels/push.rb +3 -1
- data/levels/push_branch.rb +12 -11
- data/levels/push_tags.rb +2 -1
- data/levels/rebase.rb +1 -0
- data/levels/rebase_onto.rb +46 -0
- data/levels/remote.rb +3 -2
- data/levels/remote_add.rb +1 -0
- data/levels/remote_url.rb +2 -1
- data/levels/rename.rb +1 -0
- data/levels/rename_commit.rb +2 -1
- data/levels/reorder.rb +1 -0
- data/levels/repack.rb +1 -0
- data/levels/reset.rb +2 -1
- data/levels/reset_soft.rb +1 -0
- data/levels/restore.rb +3 -2
- data/levels/restructure.rb +3 -1
- data/levels/revert.rb +2 -2
- data/levels/rm.rb +6 -3
- data/levels/rm_cached.rb +3 -2
- data/levels/squash.rb +2 -1
- data/levels/stage_lines.rb +2 -1
- data/levels/stash.rb +2 -1
- data/levels/status.rb +2 -1
- data/levels/submodule.rb +10 -9
- data/levels/tag.rb +1 -0
- data/lib/githug/cli.rb +9 -3
- data/lib/githug/level.rb +1 -1
- data/lib/githug/version.rb +1 -1
- data/lib/githug.rb +1 -0
- data/spec/githug/cli_spec.rb +12 -0
- data/spec/githug/profile_spec.rb +1 -1
- data/spec/githug_spec.rb +6 -0
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a61d7135f677a3cf9505492d8ec9914fd1fb245accf70e2a16b11f6164a53ea
|
4
|
+
data.tar.gz: be924975c33f0d6695586e495747cdc49ecedb77ae25ea89de91d386a8a925dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b3f4971ab4e041195e23ff567213c10765d518c1eb0886484d708e92761741bd7974b905f4660604e4fca4dfedfbf1b159381e64c3f8d9b1bc0e0198601c66b
|
7
|
+
data.tar.gz: 87d1f7b45360770818033c51ef243954d19a02266bcf0834d98688deed263586d426b0f6f4015d96c1e20f3111a1474f56f3500ce1cc830c858ef6a731e0ea76
|
data/.travis.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
dist: focal
|
3
3
|
rvm:
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
-
|
4
|
+
- 2.4.10
|
5
|
+
- 2.5.9
|
6
|
+
- 2.6.8
|
7
|
+
- 2.7.4
|
8
|
+
- 3.0.1
|
9
9
|
- ruby-head
|
10
10
|
|
11
11
|
matrix:
|
@@ -13,6 +13,6 @@ matrix:
|
|
13
13
|
- rvm: ruby-head
|
14
14
|
|
15
15
|
before_install:
|
16
|
-
- gem update --system
|
16
|
+
- gem update --system
|
17
17
|
- git config --global user.email 'user@example.com'
|
18
18
|
- git config --global user.name 'Test User'
|
data/Dockerfile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
FROM ruby:slim
|
2
|
+
|
3
|
+
LABEL org.opencontainers.image.authors="diraneyya@ip.rwth-aachen.de"
|
4
|
+
|
5
|
+
# This is in order to have the man pages during exercises
|
6
|
+
RUN sed -i '/path-exclude \/usr\/share\/man/d' /etc/dpkg/dpkg.cfg.d/docker
|
7
|
+
RUN sed -i '/path-exclude \/usr\/share\/groff/d' /etc/dpkg/dpkg.cfg.d/docker
|
8
|
+
RUN apt update && apt install -y man git && apt install --reinstall coreutils
|
9
|
+
|
10
|
+
# The DATA_PATH is used for the deliverables, or the submissible
|
11
|
+
# content for the classroom activity.
|
12
|
+
ENV DATA_PATH="/data"
|
13
|
+
# The REPO_PATH is where the original or the teacher's forked repo
|
14
|
+
# resides inside the container.
|
15
|
+
ENV REPO_PATH="/root/githug"
|
16
|
+
# The LEVEL_PATH is where the current challenge resides and where
|
17
|
+
# students should navigate prior to attemping to use the `githug`
|
18
|
+
# commands.
|
19
|
+
ENV LEVEL_PATH="/git_hug"
|
20
|
+
ENV GITHUG_GITCONF="/root/.gitconfig"
|
21
|
+
ENV GITHUG_PROFILE="$LEVEL_PATH/.profile.yml"
|
22
|
+
ENV GITHUG_HISTORY_OUTPUT="$DATA_PATH/history.txt"
|
23
|
+
ENV GITHUG_PROFILE_OUTPUT="$DATA_PATH/profile.yml"
|
24
|
+
ENV GITHUG_GITCONF_OUTPUT="$DATA_PATH/gitconfig"
|
25
|
+
|
26
|
+
RUN mkdir -p $DATA_PATH
|
27
|
+
ADD . $REPO_PATH
|
28
|
+
WORKDIR $REPO_PATH
|
29
|
+
RUN gem build
|
30
|
+
RUN gem install *.gem
|
31
|
+
|
32
|
+
WORKDIR /
|
33
|
+
RUN echo "y" | $GEM_HOME/bin/githug
|
34
|
+
RUN cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT
|
35
|
+
|
36
|
+
WORKDIR $LEVEL_PATH
|
37
|
+
|
38
|
+
# The bash login script in below clears the history and restores
|
39
|
+
# progress using the contents of the $GITHUG_PROFILE_OUTPUT file.
|
40
|
+
RUN printf "history -c\nHISTSIZE= \nHISTFILESIZE= \n\
|
41
|
+
echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT \n\
|
42
|
+
if ! [ -e $GITHUG_PROFILE_OUTPUT ]; then \n\
|
43
|
+
echo 'ERROR: Corrupt level progress data. Exiting.' \n\
|
44
|
+
echo '>>> CORRUPT DATA <<<' >> $GITHUG_HISTORY_OUTPUT \n\
|
45
|
+
exit 1; fi \n\
|
46
|
+
cp $GITHUG_GITCONF_OUTPUT $GITHUG_GITCONF \n\
|
47
|
+
mkdir -p $LEVEL_PATH && cp $GITHUG_PROFILE_OUTPUT $GITHUG_PROFILE \n\
|
48
|
+
export PATH=\"\$GEM_HOME/bin:\$PATH\" \n\
|
49
|
+
cd $LEVEL_PATH && githug reset \n\
|
50
|
+
echo -e '\nIMPORTANT: everything you type in this container is \
|
51
|
+
recorded to assist in the grading process.' \n" >> ~/.bash_profile
|
52
|
+
|
53
|
+
RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT \n\
|
54
|
+
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n\
|
55
|
+
cp $GITHUG_GITCONF $GITHUG_GITCONF_OUTPUT 2>/dev/null \n\
|
56
|
+
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n" >> ~/.bash_logout
|
57
|
+
|
58
|
+
ENTRYPOINT ["/bin/bash", "--login"]
|
59
|
+
VOLUME $DATA_PATH
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Githug
|
2
|
-
Git Your Game On
|
2
|
+
Git Your Game On
|
3
|
+
|
4
|
+
[![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)
|
5
|
+
|
3
6
|
## About
|
4
7
|
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.
|
5
8
|
|
@@ -28,6 +31,10 @@ To install Githug, run
|
|
28
31
|
If you get a complaint about permissions, you can rerun the command with `sudo`:
|
29
32
|
|
30
33
|
sudo gem install githug
|
34
|
+
|
35
|
+
#### Usage with Docker
|
36
|
+
|
37
|
+
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)).
|
31
38
|
|
32
39
|
### Starting the Game
|
33
40
|
|
@@ -142,6 +149,39 @@ The easiest way to test a level is:
|
|
142
149
|
* Solve the level
|
143
150
|
* Run `githug test PATH_TO_YOUR_LEVEL`
|
144
151
|
|
145
|
-
Please note that the `githug test` command can be run as `githug test --errors` to get an error
|
152
|
+
Please note that the `githug test` command can be run as `githug test --errors` to get an error stack trace from your solve method.
|
146
153
|
|
147
154
|
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.
|
155
|
+
|
156
|
+
## FAQs
|
157
|
+
|
158
|
+
1. Answers are not being checked properly
|
159
|
+
|
160
|
+
*This is a common issue we are facing and we are actively working to fix it.*
|
161
|
+
|
162
|
+
For now, run the following commands to change the default branch name to master. This should fix most of the issues you may face.
|
163
|
+
```
|
164
|
+
$ git config --global init.defaultBranch master
|
165
|
+
$ githug reset
|
166
|
+
```
|
167
|
+
|
168
|
+
From the current level forward, the default branch will be `master`.
|
169
|
+
|
170
|
+
2. `githug` command doesn't work
|
171
|
+
|
172
|
+
Githug currently isn't supported on ruby versions ^3.0.0. Use any ruby version below 3.0.0 (preferrably 2.7.1).
|
173
|
+
|
174
|
+
If you use rvm, execute the below commands
|
175
|
+
|
176
|
+
```
|
177
|
+
$ rvm install 2.7.1
|
178
|
+
$ rvm use 2.7.1
|
179
|
+
```
|
180
|
+
|
181
|
+
If you use rbenv, execute the below commands
|
182
|
+
|
183
|
+
```
|
184
|
+
$ rbenv install 2.7.1
|
185
|
+
$ rbenv global 2.7.1
|
186
|
+
```
|
187
|
+
|
data/githug.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "githug"
|
7
7
|
s.version = Githug::VERSION
|
8
8
|
s.authors = ["Gary Rennie"]
|
9
|
-
s.email = ["
|
9
|
+
s.email = ["gazler@gmail.com"]
|
10
10
|
s.homepage = "https://github.com/Gazler/githug"
|
11
11
|
s.summary = %q{An interactive way to learn git.}
|
12
12
|
s.description = %q{An interactive way to learn git.}
|
@@ -23,6 +23,5 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.add_dependency "grit", "~>2.3.0"
|
25
25
|
s.add_dependency "thor", "~>0.14.6"
|
26
|
-
s.add_dependency "rake"
|
27
|
-
# s.add_runtime_dependency "rest-client"
|
26
|
+
s.add_dependency "rake", "<11"
|
28
27
|
end
|
data/levels/add.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
difficulty 1
|
2
|
-
description "There is a file in your folder called `README
|
3
|
-
Note:
|
2
|
+
description "There is a file in your folder called `README`; add it to your staging area.
|
3
|
+
Note: Each level starts with a new repo. Don't look for files of the previous one."
|
4
4
|
|
5
5
|
setup do
|
6
6
|
repo.init
|
7
7
|
FileUtils.touch("README")
|
8
|
+
system "git branch -m master"
|
8
9
|
end
|
9
10
|
|
10
11
|
solution do
|
data/levels/bisect.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
difficulty 3
|
2
|
-
description "A bug was introduced somewhere along the way.
|
2
|
+
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?"
|
3
3
|
|
4
4
|
setup do
|
5
5
|
init_from_level
|
6
6
|
repo.init
|
7
|
+
system "git branch -m master"
|
7
8
|
end
|
8
9
|
|
9
10
|
solution do
|
data/levels/blame.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "
|
2
|
+
description "Identify who put a password inside the file `config.rb`."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
init_from_level
|
6
|
+
system "git branch -m master"
|
6
7
|
end
|
7
8
|
|
8
9
|
solution do
|
9
10
|
offender = repo.commit("97bdd0cccf9f4b8730f78cb53a81a74f205dbcc2").author.name
|
10
|
-
request("Who made the commit with the password?").downcase == offender.downcase
|
11
|
+
request("Who made the commit with the password?").downcase.strip == offender.downcase
|
11
12
|
end
|
12
13
|
|
13
14
|
hint do
|
data/levels/branch.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
difficulty 1
|
2
|
-
description "
|
2
|
+
description "To work on a piece of code that has the potential to break things, create the branch test_code."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
6
6
|
FileUtils.touch("README")
|
7
7
|
repo.add "README"
|
8
8
|
repo.commit_all("Initial commit")
|
9
|
+
system "git branch -m master"
|
9
10
|
end
|
10
11
|
|
11
12
|
solution do
|
data/levels/branch_at.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 3
|
2
|
-
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."
|
2
|
+
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."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
@@ -12,11 +12,12 @@ setup do
|
|
12
12
|
File.open("file1", 'a') { |f| f.write("\nAdding some more text") }
|
13
13
|
repo.add("file1")
|
14
14
|
repo.commit_all("Updating file1 again")
|
15
|
+
system "git branch -m master"
|
15
16
|
end
|
16
17
|
|
17
18
|
solution do
|
18
19
|
return false unless repo.branches.map(&:name).include?("test_branch")
|
19
|
-
repo.commits("test_branch").each { |commit| return false if commit.message ==
|
20
|
+
repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" }
|
20
21
|
true
|
21
22
|
end
|
22
23
|
|
data/levels/checkout.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "Create and switch to a new branch called my_branch.
|
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."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
6
6
|
FileUtils.touch("README")
|
7
7
|
repo.add("README")
|
8
8
|
repo.commit_all("initial commit")
|
9
|
+
system "git branch -m master"
|
9
10
|
end
|
10
11
|
|
11
12
|
solution do
|
data/levels/checkout_file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
difficulty 3
|
2
2
|
|
3
|
-
description "A file has been modified, but you don't want to keep the modification.
|
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."
|
4
4
|
|
5
5
|
setup do
|
6
6
|
repo.init
|
@@ -14,6 +14,7 @@ setup do
|
|
14
14
|
File.open("config.rb", "a") do |file|
|
15
15
|
file.puts("These are changed you don't want to keep!")
|
16
16
|
end
|
17
|
+
system "git branch -m master"
|
17
18
|
end
|
18
19
|
|
19
20
|
solution do
|
data/levels/checkout_tag.rb
CHANGED
data/levels/cherry-pick.rb
CHANGED
@@ -2,8 +2,9 @@ difficulty 3
|
|
2
2
|
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."
|
3
3
|
|
4
4
|
setup do
|
5
|
-
|
6
|
-
|
5
|
+
init_from_level
|
6
|
+
`git stash` # fix for README.md being in githug root an the level
|
7
|
+
system "git branch -m master"
|
7
8
|
end
|
8
9
|
|
9
10
|
solution do
|
@@ -13,5 +14,5 @@ solution do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
hint do
|
16
|
-
puts "Sneak a peek at the `cherry-pick` command."
|
17
|
+
puts "Sneak a peek at the `git help cherry-pick` command."
|
17
18
|
end
|
data/levels/clone_to_folder.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 1
|
2
|
-
description "Clone the repository at https://github.com/Gazler/cloneme
|
2
|
+
description "Clone the repository at https://github.com/Gazler/cloneme into the folder `my_cloned_repo`."
|
3
3
|
|
4
4
|
solution do
|
5
5
|
repo("my_cloned_repo").commit("157b2b61f29ab9df45f31c7cd9cb5d8ff06ecde4")
|
data/levels/commit.rb
CHANGED
data/levels/commit_amend.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit.
|
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."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
@@ -7,6 +7,7 @@ setup do
|
|
7
7
|
repo.add("README")
|
8
8
|
repo.commit_all("Initial commit")
|
9
9
|
FileUtils.touch("forgotten_file.rb")
|
10
|
+
system "git branch -m master"
|
10
11
|
end
|
11
12
|
|
12
13
|
solution do
|
data/levels/commit_in_future.rb
CHANGED
@@ -8,6 +8,7 @@ setup do
|
|
8
8
|
|
9
9
|
FileUtils.touch("README")
|
10
10
|
repo.add("README")
|
11
|
+
system "git branch -m master"
|
11
12
|
end
|
12
13
|
|
13
14
|
solution do
|
@@ -15,5 +16,5 @@ solution do
|
|
15
16
|
end
|
16
17
|
|
17
18
|
hint do
|
18
|
-
puts "Build a time
|
19
|
+
puts "Build a time format, and commit your code using --date parameter for \"future\"."
|
19
20
|
end
|
data/levels/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 1
|
2
|
-
description "Set up your git name and email
|
2
|
+
description "Set up your git name and email; this is important so that your commits can be identified."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
@@ -29,5 +29,5 @@ solution do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
hint do
|
32
|
-
puts "These settings are config settings.
|
32
|
+
puts "These settings are config settings. You should run `git help config` if you are stuck."
|
33
33
|
end
|
data/levels/conflict.rb
CHANGED
data/levels/contribute.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 3
|
2
|
-
description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub.
|
2
|
+
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."
|
3
3
|
|
4
4
|
solution do
|
5
5
|
location = "/tmp/githug"
|
data/levels/delete_branch.rb
CHANGED
@@ -3,7 +3,8 @@ difficulty 2
|
|
3
3
|
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."
|
4
4
|
|
5
5
|
setup do
|
6
|
-
|
6
|
+
init_from_level
|
7
|
+
system "git branch -m master"
|
7
8
|
end
|
8
9
|
|
9
10
|
solution do
|
@@ -12,4 +13,4 @@ end
|
|
12
13
|
|
13
14
|
hint do
|
14
15
|
puts "Running 'git --help branch' will give you a list of branch commands."
|
15
|
-
end
|
16
|
+
end
|
data/levels/diff.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "
|
2
|
+
description "Since your last commit, file `app.rb` was modified. Find out which line has changed."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
init_from_level
|
6
|
+
system "git branch -m master"
|
6
7
|
end
|
7
8
|
|
8
9
|
solution do
|
@@ -12,5 +13,5 @@ solution do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
hint do
|
15
|
-
puts "You are looking for the difference since your last commit.
|
16
|
+
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."
|
16
17
|
end
|
data/levels/fetch.rb
CHANGED
@@ -9,8 +9,9 @@ setup do
|
|
9
9
|
|
10
10
|
# local repo
|
11
11
|
repo.init
|
12
|
+
system "git branch -m master"
|
12
13
|
|
13
|
-
|
14
|
+
# adds a file to origin/master
|
14
15
|
FileUtils.touch "master_file"
|
15
16
|
repo.add "master_file"
|
16
17
|
repo.commit_all 'Commits master_file'
|
@@ -19,12 +20,12 @@ setup do
|
|
19
20
|
Dir.chdir tmpdir
|
20
21
|
repo.init
|
21
22
|
|
22
|
-
#adds a file to origin/master
|
23
|
+
# adds a file to origin/master
|
23
24
|
FileUtils.touch "master_file"
|
24
25
|
repo.add "master_file"
|
25
26
|
repo.commit_all 'Commits master_file'
|
26
|
-
|
27
|
-
#adds remote repo
|
27
|
+
|
28
|
+
# adds remote repo
|
28
29
|
Dir.chdir cwd
|
29
30
|
`git remote add origin #{tmpdir}/.git`
|
30
31
|
`git fetch origin --quiet`
|
@@ -38,31 +39,30 @@ setup do
|
|
38
39
|
FileUtils.touch "file1"
|
39
40
|
repo.add "file1"
|
40
41
|
repo.commit_all 'Commits file 1'
|
41
|
-
|
42
|
+
|
42
43
|
end
|
43
44
|
|
44
45
|
solution do
|
45
46
|
repo.init
|
46
47
|
result = true
|
47
48
|
|
48
|
-
|
49
49
|
# counts the number of local branches. Should equal 1
|
50
50
|
local_branches = repo.branches.size
|
51
51
|
|
52
52
|
# after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line
|
53
|
-
# This command will count the number of lines, which will give the number of branches
|
54
|
-
if File.file?('.git/FETCH_HEAD') #checks for file
|
55
|
-
|
53
|
+
# This command will count the number of lines, which will give the number of branches
|
54
|
+
if File.file?('.git/FETCH_HEAD') # checks for file existence
|
55
|
+
num_remote = File.read(".git/FETCH_HEAD").split("\n").count
|
56
56
|
else
|
57
|
-
|
57
|
+
num_remote = 0
|
58
58
|
end
|
59
59
|
|
60
60
|
# there should be 1 local branch and 2 remote branches for a success condition
|
61
61
|
if local_branches == 1 and num_remote == 2
|
62
|
-
|
62
|
+
result = true
|
63
63
|
else
|
64
|
-
|
65
|
-
end
|
64
|
+
result = false
|
65
|
+
end
|
66
66
|
end
|
67
67
|
|
68
68
|
hint do
|
data/levels/find_old_branch.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
difficulty 4
|
2
|
-
description "You have been working on a branch but got distracted by a major issue
|
2
|
+
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."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
init_from_level
|
6
|
+
system "git branch -m master"
|
6
7
|
end
|
7
8
|
|
8
9
|
solution do
|
data/levels/grep.rb
CHANGED
data/levels/ignore.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open.
|
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`."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
6
6
|
FileUtils.touch("README.swp")
|
7
|
+
system "git branch -m master"
|
7
8
|
file = File.open(".git/config", "w") do |file|
|
8
9
|
file.puts "[core]\nexcludesfile="
|
9
10
|
end
|
data/levels/include.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "Notice a few files with the '.a' extension.
|
2
|
+
description "Notice a few files with the '.a' extension. We want git to ignore all the files except the 'lib.a' file."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
6
6
|
FileUtils.touch("first.a")
|
7
7
|
FileUtils.touch("second.a")
|
8
8
|
FileUtils.touch("lib.a")
|
9
|
+
system "git branch -m master"
|
9
10
|
file = File.open(".git/config", "w") do |file|
|
10
11
|
file.puts "[core]\nexcludesfile="
|
11
12
|
end
|
@@ -17,5 +18,5 @@ solution do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
hint do
|
20
|
-
puts "Using `git
|
21
|
+
puts "Using `git help ignore`, read about the optional prefix to negate a pattern."
|
21
22
|
end
|
data/levels/init.rb
CHANGED
data/levels/log.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
difficulty 2
|
2
2
|
|
3
|
-
description "
|
3
|
+
description "Identify the hash of the latest commit."
|
4
4
|
|
5
5
|
setup do
|
6
6
|
repo.init
|
7
7
|
file = File.new("newfile.rb", "w")
|
8
8
|
repo.add("newfile.rb")
|
9
9
|
repo.commit_all("THIS IS THE COMMIT YOU ARE LOOKING FOR!")
|
10
|
+
system "git branch -m master"
|
10
11
|
end
|
11
12
|
|
12
13
|
solution do
|
@@ -14,5 +15,5 @@ solution do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
hint do
|
17
|
-
puts "You need to investigate the logs.
|
18
|
+
puts "You need to investigate the logs. There is probably a command for doing that!"
|
18
19
|
end
|
data/levels/merge.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
difficulty 2
|
2
|
-
description "We have a file in the branch 'feature'
|
2
|
+
description "We have a file in the branch 'feature'. Let's merge it with the master branch."
|
3
3
|
|
4
4
|
setup do
|
5
|
-
|
5
|
+
init_from_level
|
6
|
+
system "git branch -m master"
|
6
7
|
end
|
7
8
|
|
8
9
|
solution do
|
9
|
-
|
10
|
+
File.exists?("file1") && File.exists?("file2")
|
10
11
|
end
|
11
12
|
|
12
13
|
hint do
|
data/levels/merge_squash.rb
CHANGED