From c79de4b2dfefc1d8948ad197a2c66b1132a7b5ca Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Wed, 10 Jun 2020 02:01:27 +0200 Subject: [PATCH] Point to correct github location (#77) fixes #70 --- src/Page/Packages.elm | 27 ++++++++++----------------- src/Search.elm | 7 ++++--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Page/Packages.elm b/src/Page/Packages.elm index faf86f6..8e084e0 100644 --- a/src/Page/Packages.elm +++ b/src/Page/Packages.elm @@ -190,9 +190,8 @@ viewResultItemDetails channel item = asLink value = a [ href value ] [ text value ] - -- TODO: this should take channel into account as well - githubUrlPrefix = - "https://github.com/NixOS/nixpkgs-channels/blob/nixos-unstable/" + githubUrlPrefix branch = + "https://github.com/NixOS/nixpkgs-channels/blob/" ++ branch ++ "/" cleanPosition value = if String.startsWith "source/" value then @@ -202,9 +201,14 @@ viewResultItemDetails channel item = value asGithubLink value = - a - [ href <| githubUrlPrefix ++ (value |> String.replace ":" "#L" |> cleanPosition) ] - [ text <| cleanPosition value ] + case Search.channelDetailsFromId channel of + Just channelDetails -> + a + [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition) ] + [ text <| cleanPosition value ] + + Nothing -> + text <| cleanPosition value withDefault wrapWith maybe = case maybe of @@ -217,15 +221,6 @@ viewResultItemDetails channel item = Just 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 = List.member platform [ "x86_64-linux" @@ -287,8 +282,6 @@ viewResultItemDetails channel item = [ dt [] [ text "Install command" ] , dd [] [ code [] [ text <| "nix-env -iA nixos." ++ item.source.attr_name ] ] , dt [] [ text <| "Nix expression" ] - - -- TODO: point to correct branch/channel , dd [] [ withDefault asGithubLink item.source.position ] , dt [] [ text "Platforms" ] , dd [] [ ul [ class "inline" ] <| showPlatforms item.source.platforms ] diff --git a/src/Search.elm b/src/Search.elm index 6b66abc..239fab7 100644 --- a/src/Search.elm +++ b/src/Search.elm @@ -232,6 +232,7 @@ type alias ChannelDetails = { id : String , title : String , jobset : String + , branch : String } @@ -239,13 +240,13 @@ channelDetails : Channel -> ChannelDetails channelDetails channel = case channel of Unstable -> - ChannelDetails "unstable" "unstable" "nixos/trunk-combined" + ChannelDetails "unstable" "unstable" "nixos/trunk-combined" "nixos-unstable" 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 -> - 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