Sha256: 2e9f3399744e4b42c7fbf413b82e0a1e0c9ddbca73c60737c1b269a3c133ad94

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 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!/
  file.close

  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

7 entries across 7 versions & 2 rubygems

Version Path
mygithug-0.5.1 levels/merge_squash.rb
githug-0.5.0 levels/merge_squash.rb
githug-0.4.8 levels/merge_squash.rb
githug-0.4.7 levels/merge_squash.rb
githug-0.4.6 levels/merge_squash.rb
githug-0.4.5 levels/merge_squash.rb
githug-0.4.4 levels/merge_squash.rb