Git-annex remote can be specified when triggering an evaluation

This commit is contained in:
Filip Graliński 2018-12-07 09:11:50 +01:00
parent c992583a34
commit de7c1a262d

View File

@ -210,9 +210,10 @@ postTriggerLocallyR = do
(Just challengeName) <- lookupPostParam "challenge" (Just challengeName) <- lookupPostParam "challenge"
(Just localId) <- lookupPostParam "user" (Just localId) <- lookupPostParam "user"
mBranch <- lookupPostParam "branch" mBranch <- lookupPostParam "branch"
mGitAnnexRemote <- lookupPostParam "git-annex-remote"
[Entity userId _] <- runDB $ selectList [UserLocalId ==. Just localId] [] [Entity userId _] <- runDB $ selectList [UserLocalId ==. Just localId] []
let localRepo = gitServer ++ localId ++ "/" ++ challengeName let localRepo = gitServer ++ localId ++ "/" ++ challengeName
trigger userId challengeName localRepo mBranch trigger userId challengeName localRepo mBranch mGitAnnexRemote
postTriggerRemotelyR :: Handler TypedContent postTriggerRemotelyR :: Handler TypedContent
postTriggerRemotelyR = do postTriggerRemotelyR = do
@ -220,11 +221,12 @@ postTriggerRemotelyR = do
(Just url) <- lookupPostParam "url" (Just url) <- lookupPostParam "url"
(Just token) <- lookupPostParam "token" (Just token) <- lookupPostParam "token"
mBranch <- lookupPostParam "branch" mBranch <- lookupPostParam "branch"
mGitAnnexRemote <- lookupPostParam "git-annex-remote"
[Entity userId _] <- runDB $ selectList [UserTriggerToken ==. Just token] [] [Entity userId _] <- runDB $ selectList [UserTriggerToken ==. Just token] []
trigger userId challengeName url mBranch trigger userId challengeName url mBranch mGitAnnexRemote
trigger :: UserId -> Text -> Text -> Maybe Text -> Handler TypedContent trigger :: UserId -> Text -> Text -> Maybe Text -> Maybe Text -> Handler TypedContent
trigger userId challengeName url mBranch = do trigger userId challengeName url mBranch mGitAnnexRemote = do
let branch = fromMaybe "master" mBranch let branch = fromMaybe "master" mBranch
mChallengeEnt <- runDB $ getBy $ UniqueName challengeName mChallengeEnt <- runDB $ getBy $ UniqueName challengeName
case mChallengeEnt of case mChallengeEnt of
@ -232,7 +234,7 @@ trigger userId challengeName url mBranch = do
Nothing Nothing Nothing Nothing
RepoSpec {repoSpecUrl=url, RepoSpec {repoSpecUrl=url,
repoSpecBranch=branch, repoSpecBranch=branch,
repoSpecGitAnnexRemote=Nothing} repoSpecGitAnnexRemote=mGitAnnexRemote}
Nothing -> return $ toTypedContent (("Unknown challenge `" ++ (Data.Text.unpack challengeName) ++ "`. Cannot be triggered, must be submitted manually at Gonito.net!\n") :: String) Nothing -> return $ toTypedContent (("Unknown challenge `" ++ (Data.Text.unpack challengeName) ++ "`. Cannot be triggered, must be submitted manually at Gonito.net!\n") :: String)
doCreateSubmission :: UserId -> Key Challenge -> Maybe Text -> Maybe Text -> RepoSpec -> Channel -> Handler () doCreateSubmission :: UserId -> Key Challenge -> Maybe Text -> Maybe Text -> RepoSpec -> Channel -> Handler ()