Method: Gitdocs::Repository#merge

Defined in:
lib/gitdocs/repository.rb

#mergenil, ...

Merge the repository

Returns:

  • (nil)

    if the repository is invalid

  • (:no_remote)

    if the remote is not yet set

  • (Array<String>)

    if there is a conflict return the Array of conflicted file names

  • (see #author_count)

    if merged with no errors or conflicts

Raises:

  • (MergeError)

    if there is an error, it it will include the message



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/gitdocs/repository.rb', line 168

def merge
  return nil        unless valid?
  return :no_remote unless remote?
  return :ok        unless remote_oid
  return :ok        if remote_oid == current_oid

  last_oid = current_oid
  @grit.git.merge(
    { raise: true, chdir: root },
    "#{@remote_name}/#{@branch_name}"
  )
  author_count(last_oid)
rescue Grit::Git::GitTimeout
  raise(MergeError, "Merge timed out for #{root}")
rescue Grit::Git::CommandFailed => e
  # HACK: The rugged in-memory index will not have been updated after the
  # Grit merge command. Reload it before checking for conflicts.
  @rugged.index.reload
  raise(MergeError, e.err) unless @rugged.index.conflicts?
  mark_conflicts
end