MCPcopy Index your code
hub / github.com/rilldata/rill / GitFetch

Function GitFetch

cli/pkg/gitutil/gitutil.go:279–306  ·  view source on GitHub ↗
(ctx context.Context, path string, config *Config)

Source from the content-addressed store, hash-verified

277}
278
279func GitFetch(ctx context.Context, path string, config *Config) error {
280 repo, err := git.PlainOpen(path)
281 if err != nil {
282 return fmt.Errorf("failed to open git repository: %w", err)
283 }
284 if config == nil || config.Username == "" {
285 // uses default git configuration
286 // go-git does not support fetching from a private repo without auth
287 // so we will trigger the git command directly
288 return RunGitFetch(ctx, path, "origin")
289 }
290 err = repo.FetchContext(ctx, &git.FetchOptions{
291 RemoteName: config.RemoteName(),
292 RemoteURL: config.Remote,
293 Auth: &githttp.BasicAuth{
294 Username: config.Username,
295 Password: config.Password,
296 },
297 })
298 if err != nil {
299 if errors.Is(err, git.NoErrAlreadyUpToDate) {
300 // no new changes to fetch, this is not an error
301 return nil
302 }
303 return fmt.Errorf("failed to fetch from remote: %w", err)
304 }
305 return nil
306}
307
308// SetRemote sets the remote by name Rill for the given repository to the provided remote URL.
309func SetRemote(path string, config *Config) error {

Calls 3

RunGitFetchFunction · 0.85
RemoteNameMethod · 0.80
ErrorfMethod · 0.65