Skip to content

Commit 5ec6be6

Browse files
author
James Somers
committed
Merge pull request #5 from jsomers/PureSin-master
Add help and ability to pass in other log options
2 parents 37141dc + 71971f0 commit 5ec6be6

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The goal is to get the longest streak! (It's harder than you think...)
1313
- [Download the `git-game` executable](https://github.com/jsomers/git-game/releases/tag/1.0)
1414
- Put it somewhere on your PATH (like /usr/local/bin)
1515
- Then, in any git repository, run `git game`
16+
- (If you'd like, you can select a subset of commits, for example, `git game --after={2014-08-08}`. For more options, see [http://gitref.org/inspect/](http://gitref.org/inspect/).)
1617

1718
## Requirements
1819

git-game

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,38 @@ Signal.trap("INT") {
66
exit 0
77
}
88

9+
def print_header
10+
puts "----------------------------------------------------------"
11+
puts " THE GIT GAME "
12+
puts "----------------------------------------------------------"
13+
puts "Welcome! The goal of the git game is to guess committers"
14+
puts "based on their commit messages.\n\n"
15+
end
16+
17+
def print_help
18+
puts "----------------------------------------------------------"
19+
puts " USAGE "
20+
puts "----------------------------------------------------------"
21+
puts "git game [extra git log options]"
22+
puts "EX: git game --after={2014-08-08}"
23+
puts "(This script already uses --no-merges and --pretty."
24+
puts "For more valid options see: http://gitref.org/inspect/)"
25+
end
26+
27+
# -- Usage Text --
28+
if ARGV.count > 0 && (input = ARGV.shift) == 'help'
29+
print_header
30+
print_help
31+
exit 0
32+
end
33+
934
# -- Parse commits --
1035
COMMIT_DELIMITER = "XXXCOMMITXXX"
1136
FIELD_DELIMITER = "|||"
1237

1338
commit_format = ["%an", "%ar", "%B"].join(FIELD_DELIMITER)
14-
raw_commits = `git log --no-merges --pretty="#{COMMIT_DELIMITER}#{commit_format}"`.split("#{COMMIT_DELIMITER}")
1539

40+
raw_commits = `git log --no-merges --pretty="#{COMMIT_DELIMITER}#{commit_format}" #{input if input}`.split("#{COMMIT_DELIMITER}")
1641
commits = []
1742
raw_commits.each do |c|
1843
next if c.strip.empty?
@@ -26,12 +51,7 @@ committers = commits.map { |c| c[:author] }.compact.uniq
2651
# -- Show welcome message --
2752
system('clear')
2853

29-
puts "----------------------------------------------------------"
30-
puts " THE GIT GAME "
31-
puts "----------------------------------------------------------"
32-
puts "Welcome! The goal of the git game is to guess committers"
33-
puts "based on their commit messages.\n\n"
34-
54+
print_header
3555
puts "You're playing in a repo with #{commits.size} commits and #{committers.size}"
3656
puts "distinct committers.\n\n"
3757

0 commit comments

Comments
 (0)