forked from filipg/gonito
Sets are used instead of strings for tags
This commit is contained in:
parent
9d67e39a06
commit
37125b8326
@ -30,7 +30,7 @@ import "Glob" System.FilePath.Glob as G
|
|||||||
|
|
||||||
data ExtractionOptions = ExtractionOptions {
|
data ExtractionOptions = ExtractionOptions {
|
||||||
extractionOptionsDescription :: Maybe Text,
|
extractionOptionsDescription :: Maybe Text,
|
||||||
extractionOptionsTags :: Maybe Text,
|
extractionOptionsTags :: Maybe (S.Set Text),
|
||||||
extractionOptionsGeneralParams :: Maybe (M.Map Text Text),
|
extractionOptionsGeneralParams :: Maybe (M.Map Text Text),
|
||||||
extractionOptionsUnwantedParams :: Maybe [Text],
|
extractionOptionsUnwantedParams :: Maybe [Text],
|
||||||
extractionOptionsParamFiles :: Maybe [String],
|
extractionOptionsParamFiles :: Maybe [String],
|
||||||
@ -74,7 +74,7 @@ combineExtractionOptions :: Maybe ExtractionOptions -> ExtractionOptions -> Extr
|
|||||||
combineExtractionOptions Nothing options = options
|
combineExtractionOptions Nothing options = options
|
||||||
combineExtractionOptions (Just otherOptions) options = ExtractionOptions {
|
combineExtractionOptions (Just otherOptions) options = ExtractionOptions {
|
||||||
extractionOptionsDescription = combineWithT extractionOptionsDescription,
|
extractionOptionsDescription = combineWithT extractionOptionsDescription,
|
||||||
extractionOptionsTags = combineWithT extractionOptionsTags,
|
extractionOptionsTags = combineWithS extractionOptionsTags,
|
||||||
extractionOptionsGeneralParams = Just $ (fromMaybe M.empty $ extractionOptionsGeneralParams options)
|
extractionOptionsGeneralParams = Just $ (fromMaybe M.empty $ extractionOptionsGeneralParams options)
|
||||||
`M.union`
|
`M.union`
|
||||||
(fromMaybe M.empty $ extractionOptionsGeneralParams otherOptions),
|
(fromMaybe M.empty $ extractionOptionsGeneralParams otherOptions),
|
||||||
@ -86,11 +86,16 @@ combineExtractionOptions (Just otherOptions) options = ExtractionOptions {
|
|||||||
Just pfs -> Just pfs,
|
Just pfs -> Just pfs,
|
||||||
extractionOptionsMLRunPath = combineWithF extractionOptionsMLRunPath }
|
extractionOptionsMLRunPath = combineWithF extractionOptionsMLRunPath }
|
||||||
where combineWithT fun = case fun options of
|
where combineWithT fun = case fun options of
|
||||||
Nothing -> fun otherOptions
|
Nothing -> fun otherOptions
|
||||||
Just v -> Just v
|
Just v -> Just v
|
||||||
combineWithF fun = case fun options of
|
combineWithF fun = case fun options of
|
||||||
Nothing -> fun otherOptions
|
Nothing -> fun otherOptions
|
||||||
Just v -> Just v
|
Just v -> Just v
|
||||||
|
combineWithS fun = case fun options of
|
||||||
|
Nothing -> fun otherOptions
|
||||||
|
Just s1 -> case fun otherOptions of
|
||||||
|
Nothing -> Just s1
|
||||||
|
Just s2 -> Just (s1 `S.union` s2)
|
||||||
|
|
||||||
extractMetadataFromRepoDir :: FilePath -> ExtractionOptions -> IO GonitoMetadata
|
extractMetadataFromRepoDir :: FilePath -> ExtractionOptions -> IO GonitoMetadata
|
||||||
extractMetadataFromRepoDir repoDir formExtractionOptions = do
|
extractMetadataFromRepoDir repoDir formExtractionOptions = do
|
||||||
@ -108,8 +113,8 @@ extractMetadataFromRepoDir repoDir formExtractionOptions = do
|
|||||||
Nothing -> "???"
|
Nothing -> "???"
|
||||||
|
|
||||||
let commitTagsParsed = parseTags mCommitTags
|
let commitTagsParsed = parseTags mCommitTags
|
||||||
let formTagsParsed = parseTags $ extractionOptionsTags extractionOptions
|
let formTagsParsed = extractionOptionsTags extractionOptions
|
||||||
let tagsParsed = union commitTagsParsed formTagsParsed
|
let tagsParsed = union commitTagsParsed $ fromMaybe S.empty formTagsParsed
|
||||||
|
|
||||||
paramFiles <- case extractionOptionsParamFiles extractionOptions of
|
paramFiles <- case extractionOptionsParamFiles extractionOptions of
|
||||||
Just paramFilesGlobs -> G.globDir (Import.map G.compile paramFilesGlobs) repoDir
|
Just paramFilesGlobs -> G.globDir (Import.map G.compile paramFilesGlobs) repoDir
|
||||||
|
@ -20,7 +20,10 @@ import Handler.Tables
|
|||||||
import Handler.TagUtils
|
import Handler.TagUtils
|
||||||
import Handler.MakePublic
|
import Handler.MakePublic
|
||||||
|
|
||||||
import Gonito.ExtractMetadata (ExtractionOptions(..), extractMetadataFromRepoDir, GonitoMetadata(..))
|
import Gonito.ExtractMetadata (ExtractionOptions(..),
|
||||||
|
extractMetadataFromRepoDir,
|
||||||
|
GonitoMetadata(..),
|
||||||
|
parseTags)
|
||||||
|
|
||||||
import qualified Text.Read as TR
|
import qualified Text.Read as TR
|
||||||
|
|
||||||
@ -242,7 +245,7 @@ doCreateSubmission userId challengeId mDescription mTags repoSpec chan = do
|
|||||||
gonitoMetadata <- liftIO
|
gonitoMetadata <- liftIO
|
||||||
$ extractMetadataFromRepoDir repoDir (ExtractionOptions {
|
$ extractMetadataFromRepoDir repoDir (ExtractionOptions {
|
||||||
extractionOptionsDescription = mDescription,
|
extractionOptionsDescription = mDescription,
|
||||||
extractionOptionsTags = mTags,
|
extractionOptionsTags = Just $ parseTags mTags,
|
||||||
extractionOptionsGeneralParams = Nothing,
|
extractionOptionsGeneralParams = Nothing,
|
||||||
extractionOptionsUnwantedParams = Nothing,
|
extractionOptionsUnwantedParams = Nothing,
|
||||||
extractionOptionsParamFiles = Nothing,
|
extractionOptionsParamFiles = Nothing,
|
||||||
|
@ -22,7 +22,7 @@ spec = do
|
|||||||
it "simple with some fields from the form" $ do
|
it "simple with some fields from the form" $ do
|
||||||
extractMetadataFromRepoDir "test/fake-git-repos/simple/" def {
|
extractMetadataFromRepoDir "test/fake-git-repos/simple/" def {
|
||||||
extractionOptionsDescription = Just "Other solution",
|
extractionOptionsDescription = Just "Other solution",
|
||||||
extractionOptionsTags = Just "other-tag,baz"
|
extractionOptionsTags = Just $ S.fromList ["other-tag", "baz"]
|
||||||
} `shouldReturn` GonitoMetadata {
|
} `shouldReturn` GonitoMetadata {
|
||||||
gonitoMetadataDescription = "Other solution",
|
gonitoMetadataDescription = "Other solution",
|
||||||
gonitoMetadataTags = S.fromList ["foo", "simple-solution", "baz", "other-tag"],
|
gonitoMetadataTags = S.fromList ["foo", "simple-solution", "baz", "other-tag"],
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit a71de45eacb63081b2b39db09c48ad3d848c2541
|
Subproject commit 262f063bfbdb6417fbc4589ea6dfb60be773e6b1
|
Loading…
Reference in New Issue
Block a user