Skip to content

Commit c386165

Browse files
committed
add and use a projectId function
1 parent 2b07903 commit c386165

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/App/Fossa/API/BuildLink.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Data.Maybe (fromMaybe)
1818
import Data.Text (Text)
1919
import Data.Text.Extra (showT)
2020
import Fossa.API.Types (ApiOpts (..), Organization (..))
21-
import Srclib.Types (Locator (..))
21+
import Srclib.Types (Locator (..), projectId)
2222
import Text.URI qualified as URI
2323
import Text.URI.Builder (
2424
PathComponent (PathComponent),
@@ -31,10 +31,10 @@ import Text.URI.Builder (
3131
import Text.URI.QQ (uri)
3232

3333
fossaProjectUrlPath :: Locator -> ProjectRevision -> [PathComponent]
34-
fossaProjectUrlPath Locator{..} ProjectRevision{..} = map PathComponent components
34+
fossaProjectUrlPath loc@Locator{..} ProjectRevision{..} = map PathComponent components
3535
where
3636
components = ["projects", project, "refs", "branch", branch, revision]
37-
project = locatorFetcher <> "+" <> locatorProject
37+
project = projectId loc
3838
revision = fromMaybe projectRevision locatorRevision
3939
-- We default to master because core does, and we need a branch to allow us to
4040
-- create links directly to builds. If this changes, then a core change should

src/App/Fossa/Analyze/Upload.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import Srclib.Types (
7070
Locator (..),
7171
SourceUnit,
7272
licenseUnitToFullSourceUnit,
73+
projectId,
7374
renderLocator,
7475
sourceUnitToFullSourceUnit,
7576
)
@@ -210,7 +211,7 @@ buildProjectSummary project locator projectUrl = do
210211
pure $
211212
Aeson.object
212213
[ "project" .= locatorProject locator
213-
, "projectId" .= (locatorFetcher locator <> "+" <> locatorProject locator)
214+
, "projectId" .= projectId locator
214215
, "revision" .= revision
215216
, "branch" .= projectBranch project
216217
, "url" .= projectUrl

src/Srclib/Types.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module Srclib.Types (
2020
renderLocator,
2121
parseLocator,
2222
pathToOriginPath,
23+
projectId,
2324
someBaseToOriginPath,
2425
somePathToOriginPath,
2526
emptyLicenseUnit,
@@ -410,6 +411,10 @@ renderLocator :: Locator -> Text
410411
renderLocator Locator{..} =
411412
locatorFetcher <> "+" <> locatorProject <> "$" <> fromMaybe "" locatorRevision
412413

414+
projectId :: Locator -> Text
415+
projectId Locator{..} =
416+
locatorFetcher <> "+" <> locatorProject
417+
413418
parseLocator :: Text -> Locator
414419
parseLocator raw = Locator fetcher project (if Text.null revision then Nothing else Just revision)
415420
where

0 commit comments

Comments
 (0)