@@ -163,32 +163,18 @@ func modifyRepositoryURL(newRepositoryURL string) error {
163
163
164
164
fmt .Printf ("Changing URL of library %s from %s to %s\n " , libraryName , oldRepositoryURL , newRepositoryURL )
165
165
166
- // Move the library Git clone to the new path.
167
- gitClonePath := func (url string ) (* paths.Path , error ) {
168
- libraryRegistration := libraries.Repo {URL : url }
169
- gitCloneSubfolder , err := libraryRegistration .AsFolder ()
170
- if err != nil {
171
- return nil , err
172
- }
173
-
174
- return paths .New (config .GitClonesFolder , gitCloneSubfolder ), nil
175
- }
176
- oldGitClonePath , err := gitClonePath (oldRepositoryURL )
166
+ // Remove the library Git clone folder. It will be cloned from the new URL on the next sync.
167
+ libraryRegistration := libraries.Repo {URL : libraryData .Repository }
168
+ gitCloneSubfolder , err := libraryRegistration .AsFolder ()
177
169
if err != nil {
178
170
return err
179
171
}
180
- newGitClonePath , err := gitClonePath (newRepositoryURL )
181
- if err != nil {
182
- return err
183
- }
184
- if err := newGitClonePath .Parent ().MkdirAll (); err != nil {
185
- return fmt .Errorf ("While creating new library Git clone path: %w" , err )
186
- }
187
- if err := backup .Backup (oldGitClonePath ); err != nil {
172
+ gitClonePath := paths .New (config .GitClonesFolder , gitCloneSubfolder )
173
+ if err := backup .Backup (gitClonePath ); err != nil {
188
174
return fmt .Errorf ("While backing up library's Git clone: %w" , err )
189
175
}
190
- if err := oldGitClonePath . Rename ( newGitClonePath ); err != nil {
191
- return fmt .Errorf ("While moving library's Git clone: %w" , err )
176
+ if err := gitClonePath . RemoveAll ( ); err != nil {
177
+ return fmt .Errorf ("While removing library's Git clone: %w" , err )
192
178
}
193
179
194
180
// Update the library repository URL in the database.
0 commit comments