Skip to content

Instantly share code, notes, and snippets.

@alebian
Created March 16, 2017 13:53
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 alebian/cafd9f3a5893ec8f77d15efe5d7f548b to your computer and use it in GitHub Desktop.
Save alebian/cafd9f3a5893ec8f77d15efe5d7f548b to your computer and use it in GitHub Desktop.
This script lets you easily see what commits were made after the last release of your project. Usefull to track changes between releases.
new_tag_version = ARGV[0]
GIT_REPOS = []
class GitRepository
GIT_MERGE_COMMITS = /(Merge pull request)|(Merge branch)/
GIT_HASH_LENGTH = 8
attr_reader :name
def initialize(name)
@name = name
end
def important_commits_after_last_tag
all_commits = `cd #{name} && git log \`git describe --tags --abbrev=0\`..HEAD --oneline`.split("\n")
useful_commits = remove_git_commits(all_commits)
remove_git_hash!(useful_commits)
end
def new_tag_message
commit_messages = important_commits_after_last_tag
output = "## Summary\n\n"
commit_messages.each do |msg|
output += "* #{msg}\n"
end
output
end
private
def remove_git_commits(commits)
commits.select { |commit| commit !~ GIT_MERGE_COMMITS }
end
def remove_git_hash!(commits)
commits.map! { |commit| commit[GIT_HASH_LENGTH..-1] }
end
end
repositories = GIT_REPOS.map { |repo| GitRepository.new(repo) }
commits = repositories.map(&:new_tag_message)
puts commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment