Sha256: e9d0ea24109a09009f5387069315b4c1e385c13f87dae7ee88b24fa088670801

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

class Gitcycle
  module Pull

    def pull(*args)
      exec_git(:pull, args) if args.length > 0

      require_git && require_config

      current_branch = branches(:current => true)

      puts "\nRetrieving branch information from gitcycle.\n".green
      branch = get('branch',
        'branch[name]' => current_branch,
        'include' => [ 'repo' ],
        'create' => 0
      )

      if branch && branch['collab']
        # Merge from collab
        merge_remote_branch(
          :owner => owner = branch['home'],
          :repo => branch['repo']['name'],
          :branch => branch['source']
        )
      elsif branch
        # Merge from upstream source branch
        merge_remote_branch(
          :owner => owner = branch['repo']['owner'],
          :repo => branch['repo']['name'],
          :branch => branch['source']
        )
      else
        puts "\nRetrieving repo information from gitcycle.\n".green
        repo = get('repo')

        # Merge from upstream branch with same name
        merge_remote_branch(
          :owner => owner = repo['owner'],
          :repo => repo['name'],
          :branch => current_branch
        )
      end

      unless branch && branch['collab'] || owner == @git_login
        # Merge from origin
        merge_remote_branch(
          :owner => @git_login,
          :repo => @git_repo,
          :branch => current_branch
        )
      end

      branch
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitcycle-0.3.5 lib/gitcycle/pull.rb
gitcycle-0.3.4 lib/gitcycle/pull.rb