Skip to content

Commit

Permalink
feat: add tag and pr number to ui (#427)
Browse files Browse the repository at this point in the history
* add tag and pr number to ui

* remove unused import, fix comment
  • Loading branch information
JayCeeJr authored Aug 6, 2021
1 parent 9ffe858 commit 7508591
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/elm/Pages/Build/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import Routes exposing (Route(..))
import String
import SvgBuilder exposing (buildStatusToIcon, stepStatusToIcon)
import Time exposing (Posix, Zone)
import Util
import Util exposing (getNameFromRef)
import Vela
exposing
( Build
Expand Down Expand Up @@ -187,12 +187,37 @@ viewPreview now zone org repo build =
[ buildStatusToIcon build.status ]

commit =
[ repoLink
, text <| String.replace "_" " " build.event
, text " ("
, a [ href build.source ] [ text <| Util.trimCommitHash build.commit ]
, text <| ")"
]
case build.event of
"pull_request" ->
[ repoLink
, text <| String.replace "_" " " build.event
, text " "
, a [ href build.source ]
[ text "#"
, text (getNameFromRef build.ref)
]
, text " ("
, a [ href build.source ] [ text <| Util.trimCommitHash build.commit ]
, text <| ")"
]

"tag" ->
[ repoLink
, text <| String.replace "_" " " build.event
, text " "
, a [ href build.source ] [ text (getNameFromRef build.ref) ]
, text " ("
, a [ href build.source ] [ text <| Util.trimCommitHash build.commit ]
, text <| ")"
]

_ ->
[ repoLink
, text <| String.replace "_" " " build.event
, text " ("
, a [ href build.source ] [ text <| Util.trimCommitHash build.commit ]
, text <| ")"
]

branch =
[ a [ href <| Util.buildBranchUrl build.clone build.branch ] [ text build.branch ] ]
Expand Down
20 changes: 20 additions & 0 deletions src/elm/Util.elm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Util exposing
, fiveSecondsMillis
, formatRunTime
, formatTestTag
, getNameFromRef
, humanReadableDateTimeFormatter
, humanReadableWithDefault
, isLoading
Expand Down Expand Up @@ -479,3 +480,22 @@ buildBranchUrl clone branch =
trimCommitHash : String -> String
trimCommitHash commit =
String.left 7 commit


{-| getNameFromRef : parses the name from git for easy consumption
-}
getNameFromRef : String -> String
getNameFromRef s =
let
sp =
String.split "/" s

n =
List.head (List.drop 2 sp)
in
case n of
Just name ->
name

_ ->
""

0 comments on commit 7508591

Please sign in to comment.