|
|
|
@ -90,8 +90,8 @@ func AddressNoCredentials(m *models.Mirror) string { |
|
|
|
|
return u.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SaveAddress writes new address to Git repository config.
|
|
|
|
|
func SaveAddress(m *models.Mirror, addr string) error { |
|
|
|
|
// UpdateAddress writes new address to Git repository and database
|
|
|
|
|
func UpdateAddress(m *models.Mirror, addr string) error { |
|
|
|
|
repoPath := m.Repo.RepoPath() |
|
|
|
|
// Remove old origin
|
|
|
|
|
_, err := git.NewCommand("remote", "rm", "origin").RunInDir(repoPath) |
|
|
|
@ -99,8 +99,12 @@ func SaveAddress(m *models.Mirror, addr string) error { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_, err = git.NewCommand("remote", "add", "origin", "--mirror=fetch", addr).RunInDir(repoPath) |
|
|
|
|
return err |
|
|
|
|
if _, err = git.NewCommand("remote", "add", "origin", "--mirror=fetch", addr).RunInDir(repoPath); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m.Repo.OriginalURL = addr |
|
|
|
|
return models.UpdateRepositoryCols(m.Repo, "original_url") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// gitShortEmptySha Git short empty SHA
|
|
|
|
|