From cd470f6bd8b0bff01a0c775c041856853ebbc4f8 Mon Sep 17 00:00:00 2001 From: Jeffrey Huynh Date: Wed, 22 May 2024 16:56:42 -0700 Subject: [PATCH 1/2] Update issueDashURL to contain correct revision branch --- src/App/Fossa/Test.hs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/App/Fossa/Test.hs b/src/App/Fossa/Test.hs index af89bf761b..aec73b8340 100644 --- a/src/App/Fossa/Test.hs +++ b/src/App/Fossa/Test.hs @@ -20,6 +20,7 @@ import App.Fossa.PreflightChecks (PreflightCommandChecks (TestChecks), preflight import App.Fossa.Subcommand (SubCommand) import App.Types ( ProjectRevision (projectName, projectRevision), + projectBranch, ) import Control.Algebra (Has) import Control.Carrier.Debug (ignoreDebug) @@ -30,7 +31,7 @@ import Control.Effect.Lift (Lift) import Control.Timeout (timeout') import Data.Aeson qualified as Aeson import Data.String.Conversion (decodeUtf8) -import Data.Text (Text) +import Data.Text (Text, replace) import Data.Text.Extra (showT) import Effect.Logger ( Logger, @@ -41,7 +42,7 @@ import Effect.Logger ( pretty, vsep, ) -import Fossa.API.Types (Issues (..)) +import Fossa.API.Types (Issue, Issues (..), issueDashURL) testSubCommand :: SubCommand TestCliOpts TestConfig testSubCommand = Config.mkSubCommand testMain @@ -84,14 +85,19 @@ testMain config = do logSticky "" logInfo "" + let updatedIssues = + case (projectBranch revision) of + Nothing -> issues + Just branch -> updateIssuesDashURL branch issues + case issuesCount issues of 0 -> do logInfo . pretty $ successMsg diffRev case outputType of TestOutputPretty -> pure () - TestOutputJson -> renderJson issues + TestOutputJson -> renderJson updatedIssues n -> do - if null (issuesIssues issues) + if null (issuesIssues updatedIssues) then logError $ vsep @@ -99,8 +105,8 @@ testMain config = do , "Check the webapp for issue details, or rerun this command with a full-access API key." ] else case outputType of - TestOutputPretty -> logError $ pretty issues - TestOutputJson -> renderJson issues + TestOutputPretty -> logError $ pretty updatedIssues + TestOutputJson -> renderJson updatedIssues fatalText $ issuesFoundMsg diffRev n where successMsg :: Maybe DiffRevision -> Text @@ -119,3 +125,15 @@ testMain config = do renderJson :: (Has (Lift IO) sig m, Has Logger sig m) => Issues -> m () renderJson = logStdout . decodeUtf8 . Aeson.encode + + -- `issueDashURL` will have the branch set to `master` for all issues. The url will contain: `/refs/branch/master` + -- Update `issueDashURL` for all issues with the current revision's branch. + updateIssuesDashURL :: Text -> Issues -> Issues + updateIssuesDashURL projectBranch issues = issues{issuesIssues = map (updateIssueDashURL projectBranch) (issuesIssues issues)} + + updateIssueDashURL :: Text -> Issue -> Issue + updateIssueDashURL projectBranch issue = issue{issueDashURL = updatedURL} + where + oldSegment = "/master/" + newSegment = "/" <> projectBranch <> "/" + updatedURL = replace oldSegment newSegment <$> issueDashURL issue From da133f57811390b8e68eec2df153465288bf4fa4 Mon Sep 17 00:00:00 2001 From: Jeffrey Huynh Date: Wed, 22 May 2024 17:02:22 -0700 Subject: [PATCH 2/2] update changelog --- Changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index e556b4ac30..b78a2a9499 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,8 @@ # FOSSA CLI Changelog -## Unreleased +## 3.9.19 - Updated the license to CPAL, an OSI-approved license similar to MPL ([#1431](https://github.com/fossas/fossa-cli/pull/1431)). +- `fossa test`: Update `issueDashURL` to contain correct branch [#1433](https://github.com/fossas/fossa-cli/pull/1433). ## v3.9.18 - Resolves an issue where `vendored-dependencies` were rescanned locally, but not in the FOSSA service,