Sha256: 10ba2e6615fe7b213d13c8354cda933eaa6bd84b39d1ca7d35226e3c3cf8f134

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 Bytes

Contents

# -*- encoding : utf-8 -*-
difficulty 4
description "你已经在本地做了几次提交,而且所有提交都Push到了远程代码库。现在你发现有一次提交(Bad commit)包含了Bug, 你需要把它回滚掉。"

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
  commit_messages = repo.commits.map(&:message)
  valid = true if repo.commits.length > 3 &&
    commit_messages.any? { |e| e =~ /(Revert )?"Bad commit"/ }
  valid
end

hint do
  puts "Try the revert command."
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mygithug-0.5.6 levels/revert.rb
mygithug-0.5.5 levels/revert.rb
mygithug-0.5.4 levels/revert.rb
mygithug-0.5.3 levels/revert.rb
mygithug-0.5.2 levels/revert.rb