Module: Braid::Operations::Mirror

Included in:
Command
Defined in:
lib/braid/operations.rb

Instance Method Summary collapse

Instance Method Details

#add_config_fileObject



233
234
235
236
# File 'lib/braid/operations.rb', line 233

def add_config_file
  exec!("git add #{CONFIG_FILE}")
  true
end

#check_merge_status(commit) ⇒ Object



238
239
240
241
242
243
244
245
246
247
# File 'lib/braid/operations.rb', line 238

def check_merge_status(commit)
  commit = find_git_revision(commit)
  # tip from spearce in #git:
  # `test z$(git merge-base A B) = z$(git rev-parse --verify A)`
  if invoke(:git_merge_base, commit, "HEAD") == commit
    raise Braid::Commands::MirrorAlreadyUpToDate
  end

  true
end

#create_work_branchObject



217
218
219
220
221
222
223
224
225
226
227
# File 'lib/braid/operations.rb', line 217

def create_work_branch
  # check if branch exists
  status, out, err = exec("git branch | grep '#{WORK_BRANCH}'")
  if status != 0
    # then create it
    msg "Creating work branch '#{WORK_BRANCH}'."
    exec!("git branch #{WORK_BRANCH}")
  end

  true
end

#fetch_remote(type, remote) ⇒ Object



249
250
251
252
253
254
255
256
257
# File 'lib/braid/operations.rb', line 249

def fetch_remote(type, remote)
  msg "Fetching data from '#{remote}'."
  case type
  when "git"
    invoke(:git_fetch, remote)
  when "svn"
    invoke(:git_svn_fetch, remote)
  end
end

#find_remote(remote) ⇒ Object



259
260
261
262
# File 'lib/braid/operations.rb', line 259

def find_remote(remote)
  # TODO clean up and maybe return more information
  !!File.readlines(".git/config").find { |line| line =~ /^\[(svn-)?remote "#{remote}"\]/ }
end

#get_current_branchObject



212
213
214
215
# File 'lib/braid/operations.rb', line 212

def get_current_branch
  status, out, err = exec!("git branch | grep '*'")
  out[2..-1]
end

#get_work_headObject



229
230
231
# File 'lib/braid/operations.rb', line 229

def get_work_head
  find_git_revision(WORK_BRANCH)
end