Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bordercases #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions git-game
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ FIELD_DELIMITER = "|||"
commit_format = ["%an", "%ar", "%B"].join(FIELD_DELIMITER)

raw_commits = `git log --no-merges --pretty="#{COMMIT_DELIMITER}#{commit_format}" #{input if input}`.split("#{COMMIT_DELIMITER}")
if $?.exitstatus != 0
exit $?.exitstatus
end

commits = []
raw_commits.each do |c|
next if c.strip.empty?
Expand All @@ -55,12 +59,13 @@ system('clear')

print_header
puts "You're playing in a repo with #{commits.size} commits and #{committers.size}"
puts "distinct committers.\n\n"
puts "distinct committers:"

committers.each do |committer|
puts committer
end

puts
puts "Ready? PRESS ENTER TO START PLAYING (Ctrl-C to quit)"

gets
Expand All @@ -69,9 +74,15 @@ system('clear')

# -- Game loop --
NUM_CHOICE = 4
commits.shuffle!

loop do
commit = commits.shuffle.pop
if commits.empty?
puts "There are no more commits left. You've beaten this repo!"
break
end

commit = commits.pop
message = commit[:message]
author = commit[:author]

Expand Down