diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-09-16 18:03:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-16 16:03:02 +0000 |
commit | c766140dad3408048ad843d0e7b4ab5d9f5777c6 (patch) | |
tree | 49cd37606ae0cb252cd16264c111c3cf5b00088d /services | |
parent | 5e039b05801a2ceeb29b23c657110af02834b57e (diff) | |
download | gitea-c766140dad3408048ad843d0e7b4ab5d9f5777c6.tar.gz gitea-c766140dad3408048ad843d0e7b4ab5d9f5777c6.zip |
Add `RemoteAddress` to mirrors (#26952)
This PR adds a new field `RemoteAddress` to both mirror types which
contains the sanitized remote address for easier (database) access to
that information. Will be used in the audit PR if merged.
Diffstat (limited to 'services')
-rw-r--r-- | services/convert/mirror.go | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/services/convert/mirror.go b/services/convert/mirror.go index f7a8e17fd0..5051104526 100644 --- a/services/convert/mirror.go +++ b/services/convert/mirror.go @@ -5,21 +5,16 @@ package convert import ( repo_model "code.gitea.io/gitea/models/repo" - "code.gitea.io/gitea/modules/git" api "code.gitea.io/gitea/modules/structs" ) // ToPushMirror convert from repo_model.PushMirror and remoteAddress to api.TopicResponse func ToPushMirror(pm *repo_model.PushMirror) (*api.PushMirror, error) { repo := pm.GetRepository() - remoteAddress, err := getRemoteAddress(repo, pm.RemoteName) - if err != nil { - return nil, err - } return &api.PushMirror{ RepoName: repo.Name, RemoteName: pm.RemoteName, - RemoteAddress: remoteAddress, + RemoteAddress: pm.RemoteAddress, CreatedUnix: pm.CreatedUnix.FormatLong(), LastUpdateUnix: pm.LastUpdateUnix.FormatLong(), LastError: pm.LastError, @@ -27,13 +22,3 @@ func ToPushMirror(pm *repo_model.PushMirror) (*api.PushMirror, error) { SyncOnCommit: pm.SyncOnCommit, }, nil } - -func getRemoteAddress(repo *repo_model.Repository, remoteName string) (string, error) { - url, err := git.GetRemoteURL(git.DefaultContext, repo.RepoPath(), remoteName) - if err != nil { - return "", err - } - // remove confidential information - url.User = nil - return url.String(), nil -} |