MCPcopy
hub / github.com/gogs/gogs / SaveAddress

Method SaveAddress

internal/database/mirror.go:141–160  ·  view source on GitHub ↗

SaveAddress writes new address to Git repository config.

(addr string)

Source from the content-addressed store, hash-verified

139
140// SaveAddress writes new address to Git repository config.
141func (m *Mirror) SaveAddress(addr string) error {
142 repoPath := m.Repo.RepoPath()
143
144 err := git.RemoteRemove(repoPath, "origin")
145 if err != nil {
146 return errors.Newf("remove remote 'origin': %v", err)
147 }
148
149 addrURL, err := url.Parse(addr)
150 if err != nil {
151 return err
152 }
153
154 err = git.RemoteAdd(repoPath, "origin", addrURL.String(), git.RemoteAddOptions{MirrorFetch: true})
155 if err != nil {
156 return errors.Newf("add remote 'origin': %v", err)
157 }
158
159 return nil
160}
161
162const gitShortEmptyID = "0000000"
163

Callers 1

SettingsPostFunction · 0.80

Calls 4

RepoPathMethod · 0.80
RemoteRemoveMethod · 0.65
RemoteAddMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected