Sha256: 684f3d63889ab194843a5556de50dbe931d4ebd5e9f2dfcce35661e0a460842c

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

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 == 3

  # 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
githug-0.3.3 levels/merge_squash.rb
githug-0.3.2 levels/merge_squash.rb
githug-0.3.1 levels/merge_squash.rb
githug-0.3.0 levels/merge_squash.rb
githug-0.2.12 levels/merge_squash.rb