githug 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/levels/commit_ammend.rb +5 -1
- data/levels/restore.rb +2 -2
- data/lib/githug/cli.rb +0 -4
- data/lib/githug/level.rb +1 -0
- data/lib/githug/repository.rb +10 -1
- data/lib/githug/version.rb +1 -1
- data/spec/githug/cli_spec.rb +0 -1
- data/spec/githug/repository_spec.rb +12 -0
- metadata +2 -2
data/levels/commit_ammend.rb
CHANGED
@@ -10,7 +10,11 @@ setup do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
solution do
|
13
|
-
|
13
|
+
# Reset config - see issue #74
|
14
|
+
file = File.open(".git/config", "w") do |file|
|
15
|
+
file.puts("[format]")
|
16
|
+
file.puts(" pretty = medium")
|
17
|
+
end
|
14
18
|
repo.commits.length == 1 && Grit::CommitStats.find_all(repo, repo.commits.first.sha).first[1].files.length == 2
|
15
19
|
end
|
16
20
|
|
data/levels/restore.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
difficulty 4
|
2
|
-
description "You decided to delete your latest commit by running `git
|
2
|
+
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."
|
3
3
|
|
4
4
|
setup do
|
5
5
|
repo.init
|
@@ -15,7 +15,7 @@ setup do
|
|
15
15
|
repo.add 'file3'
|
16
16
|
repo.commit_all 'Restore this commit'
|
17
17
|
|
18
|
-
repo.git.native :
|
18
|
+
repo.git.native :reset, { "hard" => true }, 'HEAD^'
|
19
19
|
end
|
20
20
|
|
21
21
|
solution do
|
data/lib/githug/cli.rb
CHANGED
@@ -70,10 +70,6 @@ module Githug
|
|
70
70
|
if UI.ask("No githug directory found, do you wish to create one?")
|
71
71
|
Dir.mkdir("./git_hug")
|
72
72
|
Dir.chdir("git_hug")
|
73
|
-
File.open(".gitignore", "w") do |file|
|
74
|
-
file.puts(".profile.yml")
|
75
|
-
file.puts(".gitignore")
|
76
|
-
end
|
77
73
|
else
|
78
74
|
UI.puts("Exiting")
|
79
75
|
exit
|
data/lib/githug/level.rb
CHANGED
data/lib/githug/repository.rb
CHANGED
@@ -10,12 +10,21 @@ module Githug
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def reset
|
13
|
-
dont_delete = ["..", ".", ".
|
13
|
+
dont_delete = ["..", ".", ".profile.yml"]
|
14
14
|
if File.basename(Dir.pwd) == "git_hug"
|
15
15
|
Dir.entries(Dir.pwd).each do |file|
|
16
16
|
FileUtils.rm_rf(file) unless dont_delete.include?(file)
|
17
17
|
end
|
18
18
|
end
|
19
|
+
create_gitignore
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_gitignore
|
23
|
+
Dir.chdir("git_hug") if File.exists?("./git_hug")
|
24
|
+
File.open(".gitignore", "w") do |file|
|
25
|
+
file.puts(".profile.yml")
|
26
|
+
file.puts(".gitignore")
|
27
|
+
end
|
19
28
|
end
|
20
29
|
|
21
30
|
def valid?
|
data/lib/githug/version.rb
CHANGED
data/spec/githug/cli_spec.rb
CHANGED
@@ -19,7 +19,6 @@ describe Githug::CLI do
|
|
19
19
|
Githug::UI.stub(:ask).and_return(true)
|
20
20
|
Dir.should_receive(:mkdir).with("./git_hug")
|
21
21
|
Dir.should_receive(:chdir).with("git_hug")
|
22
|
-
File.should_receive(:open).with(".gitignore", "w").and_return(true)
|
23
22
|
@cli.make_directory
|
24
23
|
end
|
25
24
|
|
@@ -6,6 +6,7 @@ describe Githug::Repository do
|
|
6
6
|
@grit = mock
|
7
7
|
Grit::Repo.stub(:new).and_return(@grit)
|
8
8
|
@repository = Githug::Repository.new
|
9
|
+
@repository.stub(:create_gitignore)
|
9
10
|
end
|
10
11
|
|
11
12
|
describe "initialize" do
|
@@ -50,6 +51,17 @@ describe Githug::Repository do
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
|
55
|
+
describe "create_gitignore" do
|
56
|
+
it "should create a gitignore" do
|
57
|
+
@repository.unstub(:create_gitignore)
|
58
|
+
File.stub(:exists?).and_return(true)
|
59
|
+
Dir.should_receive(:chdir).with("git_hug")
|
60
|
+
File.should_receive(:open).with(".gitignore", "w")
|
61
|
+
@repository.create_gitignore
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
53
65
|
describe "valid?" do
|
54
66
|
it "should be valid if grit exists" do
|
55
67
|
@repository.should be_valid
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: githug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Gary Rennie
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|