Class: MultiRepo::MergeDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/multirepo/logic/merge-descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, repo, our_revision, their_revision) ⇒ MergeDescriptor

Returns a new instance of MergeDescriptor.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/multirepo/logic/merge-descriptor.rb', line 22

def initialize(name, repo, our_revision, their_revision)
  @name = name
  @repo = repo
  @our_revision = our_revision
  @their_revision = their_revision
  
  # Revisions can be anything: "feature1", "origin/feature1", "b51f3c0", ...
  their_ref = repo.ref(their_revision)
  
  @short_commit_id = their_ref.short_commit_id
  
  @state = determine_merge_state(repo, their_ref)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/multirepo/logic/merge-descriptor.rb', line 16

def name
  @name
end

#our_revisionObject

Returns the value of attribute our_revision.



18
19
20
# File 'lib/multirepo/logic/merge-descriptor.rb', line 18

def our_revision
  @our_revision
end

#repoObject

Returns the value of attribute repo.



17
18
19
# File 'lib/multirepo/logic/merge-descriptor.rb', line 17

def repo
  @repo
end

#stateObject

Returns the value of attribute state.



20
21
22
# File 'lib/multirepo/logic/merge-descriptor.rb', line 20

def state
  @state
end

#their_revisionObject

Returns the value of attribute their_revision.



19
20
21
# File 'lib/multirepo/logic/merge-descriptor.rb', line 19

def their_revision
  @their_revision
end

Instance Method Details

#merge_descriptionObject



36
37
38
39
40
41
# File 'lib/multirepo/logic/merge-descriptor.rb', line 36

def merge_description
  case @state
  when TheirState::NON_EXISTENT then "No revision named #{@their_revision}".red
  else; "Merge '#{@state == TheirState::EXACT_REF ? @short_commit_id : @their_revision}' into '#{@our_revision}'"
  end
end

#upstream_descriptionObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/multirepo/logic/merge-descriptor.rb', line 43

def upstream_description
  case @state
  when TheirState::NON_EXISTENT then "--"
  when TheirState::EXACT_REF then "Exact ref".yellow
  when TheirState::LOCAL_NO_UPSTREAM then "Not remote-tracking".yellow
  when TheirState::UPSTREAM_NO_LOCAL then "Branch is upstream".green
  when TheirState::LOCAL_UP_TO_DATE then "Local up-to-date with upstream".green
  when TheirState::LOCAL_OUTDATED then "Local outdated compared to upstream".yellow
  when TheirState::LOCAL_UPSTREAM_DIVERGED then "Local and upstream have diverged!".red
  end
end