diff --git a/git-game b/git-game index 503eb61..f18007d 100755 --- a/git-game +++ b/git-game @@ -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? @@ -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 @@ -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]