From 3ea12678f30098fb62cb644a4099a7d28b6287d6 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 12 Nov 2018 17:01:26 +0100 Subject: [PATCH] feat: fix master download & diff links --- server/handler.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/server/handler.go b/server/handler.go index 775d5276..0ed14803 100644 --- a/server/handler.go +++ b/server/handler.go @@ -121,8 +121,6 @@ func (s *Server) ListReleaseIOS(c echo.Context) error { if build.BuildParameters["CIRCLE_JOB"] != "client.rn.ios" { continue } - - token := s.getHash(build.Branch) if _, found := oncePerBranch[build.Branch]; found && build.Branch != "master" { continue } @@ -132,18 +130,22 @@ func (s *Server) ListReleaseIOS(c echo.Context) error { branchLink = fmt.Sprintf("https://github.com/berty/berty/%s", build.Branch) } + prBranch := build.Branch branchName := build.Branch hover := "" if build.Branch == "master" { matches := masterMerge.FindAllStringSubmatch(build.Subject, -1) if len(matches) == 1 && len(matches[0]) == 3 { - oncePerBranch["pull/"+matches[0][1]] = true - branchName = fmt.Sprintf("%s (%s)", build.Branch, matches[0][1]) + pr := matches[0][1] + prBranch = "pull/" + pr + oncePerBranch[prBranch] = true + branchName = fmt.Sprintf("%s (%s)", build.Branch, pr) hover = matches[0][2] - branchLink = "https://github.com/berty/berty/pull/" + matches[0][1] + branchLink = "https://github.com/berty/berty/pull/" + pr } } + token := s.getHash(prBranch) //out, _ := json.Marshal(build) //fmt.Println(string(out)) @@ -167,12 +169,17 @@ func (s *Server) ListReleaseIOS(c echo.Context) error { //status, // FIXME: create a link /itms/release/TOKEN/ID instead of /itms/release/TOKEN/BRANCH (this way we can handle multiple artifacts per branch) - fmt.Sprintf(`download `, s.hostname, token, build.Branch), + fmt.Sprintf(`download `, s.hostname, token, prBranch), fmt.Sprintf("%s ago", durafmt.ParseShort(time.Since(*build.StopTime))), fmt.Sprintf("%s", durafmt.ParseShort(time.Duration(*build.BuildTimeMillis)*time.Millisecond)), - fmt.Sprintf(`diff`, build.Compare), } + if build != nil && build.Compare != nil { + elems = append(elems, fmt.Sprintf(`diff`, *build.Compare)) + } else { + elems = append(elems, `n/a`) + } + html += fmt.Sprintf(`%s`, strings.Join(elems, "")) } html += ``