Class: Releaser::Repo
- Inherits:
-
Object
- Object
- Releaser::Repo
- Defined in:
- lib/releaser.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
- #all_change_logs ⇒ Object
- #commits_between(start_ref, end_ref) ⇒ Object
- #create_release(tag_name) ⇒ Object
-
#initialize(path = '.') ⇒ Repo
constructor
A new instance of Repo.
- #last_change_log ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(path = '.') ⇒ Repo
Returns a new instance of Repo.
51 52 53 |
# File 'lib/releaser.rb', line 51 def initialize(path = '.') @repo = Rugged::Repository.new(Rugged::Repository.discover(path)) end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
49 50 51 |
# File 'lib/releaser.rb', line 49 def repo @repo end |
Instance Method Details
#all_change_logs ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/releaser.rb', line 82 def all_change_logs start_tag = Tag.new("HEAD", repo.last_commit) start_on = start_tag.oid == .first.oid ? nil : start_tag change_logs = [] .reduce(start_on) do |start_tag, end_tag| if start_tag commits = commits_between(start_tag.commit, end_tag.commit) change_logs << ChangeLog.new(self, start_tag, commits) end end_tag end change_logs end |
#commits_between(start_ref, end_ref) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/releaser.rb', line 98 def commits_between(start_ref, end_ref) commits = [] repo.walk(start_ref.oid) do |commit| break if commit.oid == end_ref.oid commits << commit end commits end |
#create_release(tag_name) ⇒ Object
63 64 65 |
# File 'lib/releaser.rb', line 63 def create_release(tag_name) Rugged::Reference.create(repo, "refs/tags/#{tag_name}", repo.last_commit.oid) end |
#last_change_log ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/releaser.rb', line 67 def last_change_log raise "Not enough tags in repo" if .length < 1 # Need at least one tag in the repo (two if it's the current commit) if .first.oid == repo.last_commit.oid start_tag = .first end_tag = [1] else start_tag = Tag.new("HEAD", repo.last_commit) end_tag = [0] end ChangeLog.new(self, start_tag, commits_between(repo.last_commit, end_tag.commit)) end |
#tags ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/releaser.rb', line 55 def @tags ||= repo..map do |tagname| rev = repo.rev_parse(tagname) commit = rev.respond_to?(:target) ? rev.target : rev Tag.new(tagname, commit) end.sort_by(&:time).reverse end |