Top Level Namespace
- Includes:
- Releaselog
Defined Under Namespace
Modules: Releaselog
Constant Summary
Constants included from Releaselog
Releaselog::DESCRIPTION, Releaselog::SUMMARY, Releaselog::VERSION
Instance Method Summary collapse
-
#commit(repo, refString, logger) ⇒ Object
check if the given refString (tag name or commit-hash) exists in the repo.
-
#latestTagID(repo, logger) ⇒ Object
Returns the most recent tag.
-
#parseCommit(commit, scope, logger) ⇒ Object
Parses a commit message and returns an array of Changes.
-
#searchGitLog(repo, commit_from, commit_to, scope, logger) ⇒ Object
Searches the commit log messages of all commits between ‘commit_from` and `commit_to` for changes.
-
#tagWithName(repo, name) ⇒ Object
Returns the tag with the given name (if exists).
Instance Method Details
#commit(repo, refString, logger) ⇒ Object
check if the given refString (tag name or commit-hash) exists in the repo
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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.}") return nil rescue Exception => e logger.error("Searching for commit with ref #{refString} failure: #{e.}") return nil end end |
#latestTagID(repo, logger) ⇒ Object
Returns the most recent tag
24 25 26 27 28 |
# File 'lib/git-releaselog/changelog_helpers.rb', line 24 def latestTagID(repo, logger) return nil unless repo..count > 0 = repo..sort { |t1, t2| t1.target.time <=> t2.target.time } .last end |
#parseCommit(commit, scope, logger) ⇒ Object
Parses a commit message and returns an array of Changes
37 38 39 40 41 42 43 |
# 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..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) ⇒ Object
Searches the commit log messages of all commits between ‘commit_from` and `commit_to` for changes
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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) ⇒ Object
Returns the tag with the given name (if exists)
31 32 33 34 |
# File 'lib/git-releaselog/changelog_helpers.rb', line 31 def tagWithName(repo, name) = repo..select { |t| t.name == name } return .first unless .count < 1 end |