Skip to content

Add merge --squash level #42

Merged
merged 1 commit into from Mar 27, 2012
View
48 levels/merge_squash.rb
@@ -0,0 +1,48 @@
+difficulty 3
+description "Merge all commits from the long-feature-branch as a single commit."
+
+setup do
+ repo.init
+
+ FileUtils.touch "file1"
+ repo.add "file1"
+ repo.commit_all "First commit"
+
+ repo.git.native :checkout, {b: true}, 'long-feature-branch'
+ File.open("file3", 'w') { |f| f << "some feature\n" }
+ repo.add "file3"
+ repo.commit_all "Developing new features"
+
+ File.open("file3", 'a') { |f| f << "getting awesomer\n" }
+ repo.add "file3"
+ repo.commit_all "Takes"
+
+ File.open("file3", 'a') { |f| f << "and awesomer!\n" }
+ repo.add "file3"
+ repo.commit_all "Time"
+
+ repo.git.native :checkout, {}, 'master'
+
+ FileUtils.touch "file2"
+ repo.add "file2"
+ repo.commit_all "Second commit"
+end
+
+solution do
+ result = true
+
+ # Check the number of commits in the repo (should be 4 - including initial .gitignore).
+ result = false unless repo.commits.size == 4
+
+ # Check if changes from all the commits from long-feature-branch are included.
+ file = File.open('file3')
+ result = false unless file.readline =~ /some feature/
+ result = false unless file.readline =~ /getting awesomer/
+ result = false unless file.readline =~ /and awesomer!/
+
+ result
+end
+
+hint do
+ puts "Take a look at the --squash option of the merge command. Don't forget to commit the merge!"
+end
View
3 lib/githug/level.rb
@@ -6,7 +6,8 @@ class Level
"clone_to_folder", "ignore", "status", "rm", "rm_cached", "rename",
"log", "tag", "commit_ammend", "reset", "checkout_file", "remote",
"remote_url", "pull", "remote_add", "diff", "blame", "branch", "checkout",
- "branch_at", "merge", "rename_commit", "squash", "stage_lines", "contribute"]
+ "branch_at", "merge", "rename_commit", "squash", "merge_squash",
+ "stage_lines", "contribute"]
attr_accessor :level_no, :level_path
Something went wrong with that request. Please try again.