class Object
Public Instance Methods
commit(repo, refString, logger)
click to toggle source
check if the given refString (tag name or commit-hash) exists in the repo
# File lib/git-releaselog/changelog_helpers.rb, line 8 def commit(repo, refString, logger) logger.info("Searching for ref #{refString} in repo") return unless refString != nil begin repo.lookup(refString) rescue Rugged::OdbError => e logger.error("Searching for commit with ref #{refString} failure: #{e.message}") return nil rescue Exception => e logger.error("Searching for commit with ref #{refString} failure: #{e.message}") return nil end end
latestTagID(repo, logger)
click to toggle source
Returns the most recent tag
# File lib/git-releaselog/changelog_helpers.rb, line 24 def latestTagID(repo, logger) return nil unless repo.tags.count > 0 sorted_tags = repo.tags.sort { |t1, t2| t1.target.time <=> t2.target.time } sorted_tags.last end
parseCommit(commit, scope, logger)
click to toggle source
Parses a commit message and returns an array of Changes
# File lib/git-releaselog/changelog_helpers.rb, line 37 def parseCommit(commit, scope, logger) logger.debug("Parsing Commit #{commit.oid}") # Sepaerate into lines, remove whitespaces and filter out empty lines lines = commit.message.lines.map(&:strip).reject(&:empty?) # Parse the lines lines.map{|line| Change.parse(line, scope)}.reject(&:nil?) end
searchGitLog(repo, commit_from, commit_to, scope, logger)
click to toggle source
Searches the commit log messages of all commits between ‘commit_from` and `commit_to` for changes
# File lib/git-releaselog/changelog_helpers.rb, line 46 def searchGitLog(repo, commit_from, commit_to, scope, logger) # logger.info("Traversing git tree from commit #{commit_from.oid} to commit #{commit_to && commit_to ? commit_to.oid : '(no oid)'}") # Initialize a walker that walks through the commits from the <from-commit> to the <to-commit> walker = Rugged::Walker.new(repo) walker.sorting(Rugged::SORT_DATE) walker.push(commit_to) unless commit_to == nil commit_from.parents.each do |parent| walker.hide(parent) end unless commit_from == nil # Parse all commits and extract changes changes = walker.map{ |c| parseCommit(c, scope, logger)}.reduce(:+) || [] logger.debug("Found #{changes.count} changes") return changes end
tagWithName(repo, name)
click to toggle source
Returns the tag with the given name (if exists)
# File lib/git-releaselog/changelog_helpers.rb, line 31 def tagWithName(repo, name) tags = repo.tags.select { |t| t.name == name } return tags.first unless tags.count < 1 end