Module: SRC

Defined in:
lib/src.rb,
lib/src/cli.rb,
lib/src/git.rb,
lib/src/branch.rb

Defined Under Namespace

Modules: Git Classes: Branch, CLI

Constant Summary collapse

BRANCHES =
{
  master: nil,
  hotfix: {
    branches_from: 'master',
    merges_to: 'master',
    prefix: 'hotfix',
    semantic_level: 'patch'
  },
  minor: {
    branches_from: 'develop',
    merges_to: 'master',
    prefix: 'release',
    semantic_level: 'minor'
  },
  major: {
    branches_from: 'develop',
    merges_to: 'master',
    prefix: 'release',
    semantic_level: 'major'
  },
  develop: nil
}

Class Method Summary collapse

Class Method Details

.branchesObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/src.rb', line 52

def self.branches
  @branches ||= BRANCHES.map do |k, v|
    if v
      sc_branch = SRC::Branch.new(k) if v
      sc_branch.latest if sc_branch.unmerged?
    else
      SRC::Git::Branch.new(k)
    end
  end.compact.uniq { |branch| branch.name }
end

.checkObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/src.rb', line 27

def self.check
  SRC::Git.fetch

  report = []

  branches.each_with_index do |branch, i|

    branches[(i + 1)..-1].each do |superset|
      unless branch.subset_of?(superset)
        report << "#{branch} is ahead of #{superset}"
      end
    end

    unless branch.remote_up_to_date?
      report << "#{branch} is not up to date with its remote"
    end
  end

  if report.empty?
    puts 'No merges needed.'
  else
    puts report.join("\n")
  end
end