go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/bisection/util/linkconstructor.go (about) 1 // Copyright 2022 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package util 16 17 import ( 18 "context" 19 "fmt" 20 "net/url" 21 22 "go.chromium.org/luci/bisection/internal/gerrit" 23 24 gerritpb "go.chromium.org/luci/common/proto/gerrit" 25 ) 26 27 // ConstructCompileAnalysisURL returns a link to the analysis page in LUCI Bisection 28 // given a Buildbucket ID 29 func ConstructCompileAnalysisURL(project string, bbid int64) string { 30 return fmt.Sprintf("https://ci.chromium.org/ui/p/%s/bisection/compile-analysis/b/%d", project, bbid) 31 } 32 33 // ConstructTestAnalysisURL returns a link to the analysis page in LUCI Bisection 34 // given a Buildbucket ID 35 func ConstructTestAnalysisURL(project string, analysisID int64) string { 36 return fmt.Sprintf("https://ci.chromium.org/ui/p/%s/bisection/test-analysis/b/%d", project, analysisID) 37 } 38 39 // ConstructBuildURL returns a link to the build page in Milo given a 40 // Buildbucket ID 41 func ConstructBuildURL(ctx context.Context, bbid int64) string { 42 return fmt.Sprintf("https://ci.chromium.org/b/%d", bbid) 43 } 44 45 // ConstructBuganizerURLForAnalysis returns a link to create a bug against 46 // LUCI Bisection for wrongly blamed commits 47 func ConstructBuganizerURLForAnalysis(commitReviewURL string, analysisURL string) string { 48 queryParams := url.Values{ 49 "title": {fmt.Sprintf("Wrongly blamed %s", commitReviewURL)}, 50 "description": {fmt.Sprintf("Analysis: %s", analysisURL)}, 51 "format": {"PLAIN"}, 52 "component": {"1199205"}, 53 "type": {"BUG"}, 54 "priority": {"P3"}, 55 } 56 57 return "http://b.corp.google.com/createIssue?" + queryParams.Encode() 58 } 59 60 func ConstructGerritCodeReviewURL(ctx context.Context, 61 gerritClient *gerrit.Client, change *gerritpb.ChangeInfo) string { 62 return fmt.Sprintf("https://%s/c/%s/+/%d", gerritClient.Host(ctx), 63 change.Project, change.Number) 64 } 65 66 func ConstructTestHistoryURL(project, testID, variantHash string) string { 67 queryParams := url.Values{ 68 "q": {fmt.Sprintf("VHash:%s", variantHash)}, 69 } 70 return fmt.Sprintf("https://ci.chromium.org/ui/test/%s/%s?", url.PathEscape(project), url.PathEscape(testID)) + queryParams.Encode() 71 }