From 13207458f0ba2aab64e5a9213d52f24364bf4fd8 Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Mon, 28 Aug 2023 16:57:22 +0200 Subject: [PATCH] Add GetCommitViewerURL to Forge --- tools/mothership/worker_server/forge/forge.go | 1 + tools/mothership/worker_server/forge/github/github.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/tools/mothership/worker_server/forge/forge.go b/tools/mothership/worker_server/forge/forge.go index df139b2c..25dd364e 100644 --- a/tools/mothership/worker_server/forge/forge.go +++ b/tools/mothership/worker_server/forge/forge.go @@ -18,5 +18,6 @@ type Authenticator struct { type Forge interface { GetAuthenticator() (*Authenticator, error) GetRemote() string + GetCommitViewerURL(repo string, commit string) string EnsureRepositoryExists(auth *Authenticator, repo string) error } diff --git a/tools/mothership/worker_server/forge/github/github.go b/tools/mothership/worker_server/forge/github/github.go index 93c62777..528e8889 100644 --- a/tools/mothership/worker_server/forge/github/github.go +++ b/tools/mothership/worker_server/forge/github/github.go @@ -168,6 +168,15 @@ func (f *Forge) GetRemote() string { return fmt.Sprintf("https://github.com/%s", f.organization) } +func (f *Forge) GetCommitViewerURL(repo string, commit string) string { + return fmt.Sprintf( + "https://github.com/%s/%s/commit/%s", + f.organization, + repo, + commit, + ) +} + func (f *Forge) EnsureRepositoryExists(auth *forge.Authenticator, repo string) error { // Cast AuthMethod to BasicAuth basicAuth := auth.AuthMethod.(*transport_http.BasicAuth)