Class: Celebrations::Git

Inherits:
Celebration show all
Defined in:
lib/release_party/celebrations/git.rb

Instance Attribute Summary

Attributes inherited from Celebration

#environment

Instance Method Summary collapse

Methods inherited from Celebration

#after_deploy, #before_deploy, inherited, #tasks

Constructor Details

#initialize(env) ⇒ Git

Returns a new instance of Git.



7
8
9
10
11
# File 'lib/release_party/celebrations/git.rb', line 7

def initialize(env)
  super env

  require 'grit'
end

Instance Method Details

#commit_tracker_progress(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/release_party/celebrations/git.rb', line 13

def commit_tracker_progress(env)
  # Go through each finished story id we've seen in the git repo
  # and deliver each story that is marked as finished
  env.finished_store_ids.each do |story_id|

  end
end

#load_git_progress(env) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/release_party/celebrations/git.rb', line 21

def load_git_progress(env)
  repo = Grit::Repo.new(Dir.pwd)
  config = Grit::Config.new(repo)

  feature_branch = config.fetch('gitflow.prefix.feature', 'feature/')
  release_branch = config.fetch('gitflow.prefix.release', 'release/')
  puts "Feature branch: #{feature_branch}"
  puts "Release branch: #{release_branch}"

  # Find the last release
  latest_release = \
    repo.commits('master').find do |commit|
      commit.message =~ /\AMerge branch '#{release_branch}(\d+)/
    end
  latest_release_tag = $1

  puts "Commit: #{latest_release} #{latest_release.message}"
  previous_release = \
    repo.commits('master', 100).find do |commit|
      if commit.message =~ /\AMerge branch '#{release_branch}(\d+)/ 
        latest_release_tag != $1
      end
    end
  previous_release_tag = $1
  puts "Commit: #{previous_release} #{previous_release.message}"

  env.finished_story_ids = 
    repo.commits('develop').collect do |commit|
      $1 if commit.message =~ /\AMerge branch '#{feature_branch}(\d+)/
    end.compact
  puts env.finished_story_ids
end