github.com/driusan/dgit@v0.0.0-20221118233547-f39f0c15edbb/git/pull.go (about)

     1  package git
     2  
     3  import ()
     4  
     5  type PullOptions struct {
     6  	FetchOptions
     7  	MergeOptions
     8  }
     9  
    10  func Pull(c *Client, opts PullOptions, repository Remote, remotebranches []string) error {
    11  	err := Fetch(c, opts.FetchOptions, repository, nil)
    12  	if err != nil && err.Error() != "Already up to date." {
    13  		// If fetch says we have all the refs, that doesn't
    14  		// mean that they're merged into the current branch
    15  		// so we don't error out.
    16  		return err
    17  	}
    18  
    19  	others := make([]Commitish, 0, len(remotebranches))
    20  	for _, name := range remotebranches {
    21  		c, err := RevParseCommitish(c, &RevParseOptions{}, name)
    22  		if err != nil {
    23  			return err
    24  		}
    25  		others = append(others, c)
    26  	}
    27  
    28  	return Merge(c, opts.MergeOptions, others)
    29  }