Sha256: 3568826ac397f7e68f5eba1cd7dfe191f85b1465ac3e1062f8290ad82c4cb60d

Contents?: true

Size: 840 Bytes

Versions: 14

Compression:

Stored size: 840 Bytes

Contents

difficulty 4
description "You have committed several times but want to undo the middle commit."

setup do
  repo.init

  FileUtils.touch "file1"
  repo.add        "file1"
  repo.commit_all "First commit"

  FileUtils.touch "file3"
  repo.add        "file3"
  repo.commit_all "Bad commit"

  FileUtils.touch "file2"
  repo.add        "file2"
  repo.commit_all "Second commit"
end

solution do
  valid = false
  valid = true if repo.commits.length > 3 &&
    repo.commits[3].message == "First commit" &&
    repo.commits[2].message == "Second commit" &&
    repo.commits[1].message == "Bad commit" &&
    repo.commits[0].message.split("\n").first == "Revert \"Bad commit\""
  valid = true if repo.commits[1].message == "First commit" &&
    repo.commits[0].message == "Second commit"
  valid
end

hint do
  puts "Try the revert command."
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
githug-0.3.4 levels/revert.rb
githug-0.3.3 levels/revert.rb
githug-0.3.2 levels/revert.rb
githug-0.3.1 levels/revert.rb
githug-0.3.0 levels/revert.rb
githug-0.2.12 levels/revert.rb
githug-0.2.11 levels/revert.rb
githug-0.2.10 levels/revert.rb
githug-0.2.9 levels/revert.rb
githug-0.2.8 levels/revert.rb
githug-0.2.7 levels/revert.rb
githug-0.2.6 levels/revert.rb
githug-0.2.5 levels/revert.rb
githug-0.2.4 levels/revert.rb