Method: Metaverse::Repo#send_state

Defined in:
lib/metaverse/repo.rb

#send_state(prefix, state, remote, should_clean = false) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/metaverse/repo.rb', line 130

def send_state prefix, state, remote, should_clean = false
  refs = ["refs/meta/local/#{prefix}/#{state}"]
  branch_name = "#{prefix}/#{state}"
  branch = @repo.branches[branch_name]
  develop = @repo.branches['develop']

  if branch.nil?
    Errors::ref_not_found branch_name
    return false
  end

  if develop.nil?
    Errors::ref_not_found 'develop'
    return false
  end

  if (not prefix == 'snapshot') and ahead_of_develop? branch
      refs << branch_name
      update_ref refs[0], @repo.branches[branch_name]
  end

  clean_branch branch if should_clean

  Dir.chdir(@repo.workdir) do
    `git push #{remote} #{refs.join(' ')}`
  end
end