@@ -127,24 +127,17 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
127
127
128
128
repo .IsEmpty = false
129
129
130
- // Don't bother looking this repo in the context it won't be there
131
- gitRepo , err := gitrepo .OpenRepository (ctx , repo )
132
- if err != nil {
133
- return fmt .Errorf ("openRepository: %w" , err )
134
- }
135
- defer gitRepo .Close ()
136
-
137
130
if len (defaultBranch ) > 0 {
138
131
repo .DefaultBranch = defaultBranch
139
132
140
- if err = gitRepo .SetDefaultBranch (repo .DefaultBranch ); err != nil {
133
+ if err = gitrepo .SetDefaultBranch (ctx , repo , repo .DefaultBranch ); err != nil {
141
134
return fmt .Errorf ("setDefaultBranch: %w" , err )
142
135
}
143
136
} else {
144
- repo .DefaultBranch , err = gitRepo .GetDefaultBranch ()
137
+ repo .DefaultBranch , err = gitrepo .GetDefaultBranch (ctx , repo )
145
138
if err != nil {
146
139
repo .DefaultBranch = setting .Repository .DefaultBranch
147
- if err = gitRepo .SetDefaultBranch (repo .DefaultBranch ); err != nil {
140
+ if err = gitrepo .SetDefaultBranch (ctx , repo , repo .DefaultBranch ); err != nil {
148
141
return fmt .Errorf ("setDefaultBranch: %w" , err )
149
142
}
150
143
}
@@ -188,7 +181,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
188
181
repo .DefaultBranch = setting .Repository .DefaultBranch
189
182
}
190
183
191
- if err = gitRepo .SetDefaultBranch (repo .DefaultBranch ); err != nil {
184
+ if err = gitrepo .SetDefaultBranch (ctx , repo , repo .DefaultBranch ); err != nil {
192
185
return fmt .Errorf ("setDefaultBranch: %w" , err )
193
186
}
194
187
}
@@ -197,6 +190,13 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
197
190
return fmt .Errorf ("updateRepository: %w" , err )
198
191
}
199
192
193
+ // Don't bother looking this repo in the context it won't be there
194
+ gitRepo , err := gitrepo .OpenRepository (ctx , repo )
195
+ if err != nil {
196
+ return fmt .Errorf ("openRepository: %w" , err )
197
+ }
198
+ defer gitRepo .Close ()
199
+
200
200
if err = repo_module .SyncReleasesWithTags (ctx , repo , gitRepo ); err != nil {
201
201
return fmt .Errorf ("SyncReleasesWithTags: %w" , err )
202
202
}
0 commit comments