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

Method pullInner

runtime/drivers/admin/repo_git.go:59–214  ·  view source on GitHub ↗

pullInner contains the actual logic of r.pull without retries.

(ctx context.Context, userTriggered, force bool)

Source from the content-addressed store, hash-verified

57
58// pullInner contains the actual logic of r.pull without retries.
59func (r *gitRepo) pullInner(ctx context.Context, userTriggered, force bool) error {
60 // If the repository is not editable, there shouldn't be any local changes, but just to be safe, we always force pull.
61 if !r.editable() {
62 force = true
63 }
64
65 // Check if repoDir exists and is a valid Git repository
66 if !isRepoRoot(r.repoDir) {
67 // Repository doesn't exist or is invalid, remove and clone fresh
68 if err := os.RemoveAll(r.repoDir); err != nil {
69 return err
70 }
71 // for non editable make the clone faster by only cloning the primary branch with no history
72 // for editable deployments, we need the full history and all branches to support editing and merging
73 err := gitutil.Clone(ctx, r.repoDir, r.remoteURL, r.primaryBranch, !r.editableDepl, !r.editableDepl)
74 if err != nil {
75 return err
76 }
77
78 if r.editableDepl {
79 // set git config in the repo dir to ensure git commits/git merge etc pass on cloud
80 err = setGitConfig(r.repoDir, "user.name", "Rill")
81 if err != nil {
82 return err
83 }
84 err = setGitConfig(r.repoDir, "user.email", "noreply@rilldata.com")
85 if err != nil {
86 return err
87 }
88 }
89 } else {
90 // Repository exists, pull latest changes
91
92 // Ensure the remote URL is correct
93 err := setRemoteURL(r.repoDir, r.remoteURL)
94 if err != nil {
95 return err
96 }
97
98 if !r.editableDepl {
99 // For non-editable repos, we only care about the primary branch, so set the fetch refspec to only fetch the primary branch.
100 err := setFetchBranch(r.repoDir, r.primaryBranch)
101 if err != nil {
102 return err
103 }
104 }
105
106 // Fetch the remote changes.
107 branchesToFetch := []string{r.primaryBranch}
108 if r.editableDepl && r.primaryBranch != r.defaultBranch {
109 branchesToFetch = append(branchesToFetch, r.defaultBranch)
110 }
111 err = gitutil.FetchBranches(ctx, r.repoDir, branchesToFetch...)
112 if err != nil {
113 return err
114 }
115 }
116

Callers 1

pullMethod · 0.95

Calls 15

editableMethod · 0.95
pushBranchMethod · 0.95
CloneFunction · 0.92
FetchBranchesFunction · 0.92
CheckoutFunction · 0.92
HashFunction · 0.92
MergeWithBailOnConflictFunction · 0.92
MergeWithStrategyFunction · 0.92
isRepoRootFunction · 0.85
setGitConfigFunction · 0.85
setRemoteURLFunction · 0.85
setFetchBranchFunction · 0.85

Tested by

no test coverage detected