Skip to content

Instantly share code, notes, and snippets.

@spacewander
Last active June 22, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacewander/13e18cf150b96c69ec69df0056286738 to your computer and use it in GitHub Desktop.
Save spacewander/13e18cf150b96c69ec69df0056286738 to your computer and use it in GitHub Desktop.
git-extras release script
#!/usr/bin/env ruby
# encoding: UTF-8
require 'set'
# usage: $SCRIPT <dir_of_git_extras>
Dir.chdir ARGV[0]
puts <<EOS
The git-extras $version ($release-name) is released now!
Here's a list of all the changes made in this release; the full changelog can be found in [History.md](https://github.com/tj/git-extras/blob/master/History.md):
EOS
contributor = ''
num = 0
displayed = false
latest_tag=`git describe --tags $(git rev-list --tags --max-count=1)`.chop
`git log --pretty="%B" #{latest_tag}.. --merges`.lines.each_with_index do |line, idx|
line.strip!
matches = /^Merge pull request (.+) from ([^\/]+)\//.match(line)
if matches
num = matches[1]
contributor = matches[2]
displayed = false
elsif line != "" and !displayed
puts "- (#{num}) #{line} – @#{contributor}"
displayed = true
end
end
authors = Set.new
in_contributor_section = false
File.read('AUTHORS').each_line do |line|
if line == "```````````````````````\n"
in_contributor_section = true
end
if line.start_with? "- "
if in_contributor_section
authors.add line[2..-1]
else
name = /^- (.+) </.match(line)[1]
authors.add name
end
end
end
authors.add '罗泽轩' # I don't want to be counted twice
new_authors = Set.new
`git log --pretty="%an" --no-merges #{latest_tag}..`.each_line do |line|
line.strip!
unless authors.include? line
new_authors.add "- #{line}"
authors.add line
end
end
doc_updated = `git log --oneline #{latest_tag}.. -- man/`.lines.length
install_updated = `git log --oneline #{latest_tag}.. -- \[iI\]nstall*`.lines.length
puts <<EOS
Since the last release (#{latest_tag} $last-release-name):
- updated man pages or documentation **#{doc_updated} times**
- fixed installation/update **#{install_updated} times**
- **#{new_authors.length} unique contributors**
**Break change**:
EOS
puts "\nNew authors:"
new_authors.each do |author|
puts author
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment