Point to correct github location (#77)

fixes #70
This commit is contained in:
Rok Garbas 2020-06-10 02:01:27 +02:00 committed by GitHub
parent b7df41a891
commit c79de4b2df
Failed to generate hash of commit
2 changed files with 14 additions and 20 deletions

View file

@ -190,9 +190,8 @@ viewResultItemDetails channel item =
asLink value = asLink value =
a [ href value ] [ text value ] a [ href value ] [ text value ]
-- TODO: this should take channel into account as well githubUrlPrefix branch =
githubUrlPrefix = "https://github.com/NixOS/nixpkgs-channels/blob/" ++ branch ++ "/"
"https://github.com/NixOS/nixpkgs-channels/blob/nixos-unstable/"
cleanPosition value = cleanPosition value =
if String.startsWith "source/" value then if String.startsWith "source/" value then
@ -202,10 +201,15 @@ viewResultItemDetails channel item =
value value
asGithubLink value = asGithubLink value =
case Search.channelDetailsFromId channel of
Just channelDetails ->
a a
[ href <| githubUrlPrefix ++ (value |> String.replace ":" "#L" |> cleanPosition) ] [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition) ]
[ text <| cleanPosition value ] [ text <| cleanPosition value ]
Nothing ->
text <| cleanPosition value
withDefault wrapWith maybe = withDefault wrapWith maybe =
case maybe of case maybe of
Nothing -> Nothing ->
@ -217,15 +221,6 @@ viewResultItemDetails channel item =
Just value -> Just value ->
wrapWith value wrapWith value
convertToGithubUrl value =
if String.startsWith "source/" value then
githubUrlPrefix ++ String.dropLeft 7 value
else
githubUrlPrefix ++ value
-- TODO: add links to hydra for hydra_platforms
-- example: https://hydra.nixos.org/job/nixos/release-20.03/nixpkgs.gnome3.accerciser.i686-linux
allowedPlatforms platform = allowedPlatforms platform =
List.member platform List.member platform
[ "x86_64-linux" [ "x86_64-linux"
@ -287,8 +282,6 @@ viewResultItemDetails channel item =
[ dt [] [ text "Install command" ] [ dt [] [ text "Install command" ]
, dd [] [ code [] [ text <| "nix-env -iA nixos." ++ item.source.attr_name ] ] , dd [] [ code [] [ text <| "nix-env -iA nixos." ++ item.source.attr_name ] ]
, dt [] [ text <| "Nix expression" ] , dt [] [ text <| "Nix expression" ]
-- TODO: point to correct branch/channel
, dd [] [ withDefault asGithubLink item.source.position ] , dd [] [ withDefault asGithubLink item.source.position ]
, dt [] [ text "Platforms" ] , dt [] [ text "Platforms" ]
, dd [] [ ul [ class "inline" ] <| showPlatforms item.source.platforms ] , dd [] [ ul [ class "inline" ] <| showPlatforms item.source.platforms ]

View file

@ -232,6 +232,7 @@ type alias ChannelDetails =
{ id : String { id : String
, title : String , title : String
, jobset : String , jobset : String
, branch : String
} }
@ -239,13 +240,13 @@ channelDetails : Channel -> ChannelDetails
channelDetails channel = channelDetails channel =
case channel of case channel of
Unstable -> Unstable ->
ChannelDetails "unstable" "unstable" "nixos/trunk-combined" ChannelDetails "unstable" "unstable" "nixos/trunk-combined" "nixos-unstable"
Release_19_09 -> Release_19_09 ->
ChannelDetails "19.09" "19.09" "nixos/release-19.09" ChannelDetails "19.09" "19.09" "nixos/release-19.09" "nixos-19.09"
Release_20_03 -> Release_20_03 ->
ChannelDetails "20.03" "20.03" "nixos/release-20.03" ChannelDetails "20.03" "20.03" "nixos/release-20.03" "nixos-20.03"
channelFromId : String -> Maybe Channel channelFromId : String -> Maybe Channel