From de7c1a262d8c42ff25a9ef394ab53252a232f01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Fri, 7 Dec 2018 09:11:50 +0100 Subject: [PATCH] Git-annex remote can be specified when triggering an evaluation --- Handler/ShowChallenge.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 77d57a4..3ab87bd 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -210,9 +210,10 @@ postTriggerLocallyR = do (Just challengeName) <- lookupPostParam "challenge" (Just localId) <- lookupPostParam "user" mBranch <- lookupPostParam "branch" + mGitAnnexRemote <- lookupPostParam "git-annex-remote" [Entity userId _] <- runDB $ selectList [UserLocalId ==. Just localId] [] let localRepo = gitServer ++ localId ++ "/" ++ challengeName - trigger userId challengeName localRepo mBranch + trigger userId challengeName localRepo mBranch mGitAnnexRemote postTriggerRemotelyR :: Handler TypedContent postTriggerRemotelyR = do @@ -220,11 +221,12 @@ postTriggerRemotelyR = do (Just url) <- lookupPostParam "url" (Just token) <- lookupPostParam "token" mBranch <- lookupPostParam "branch" + mGitAnnexRemote <- lookupPostParam "git-annex-remote" [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 challengeName url mBranch = do +trigger :: UserId -> Text -> Text -> Maybe Text -> Maybe Text -> Handler TypedContent +trigger userId challengeName url mBranch mGitAnnexRemote = do let branch = fromMaybe "master" mBranch mChallengeEnt <- runDB $ getBy $ UniqueName challengeName case mChallengeEnt of @@ -232,7 +234,7 @@ trigger userId challengeName url mBranch = do Nothing Nothing RepoSpec {repoSpecUrl=url, 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) doCreateSubmission :: UserId -> Key Challenge -> Maybe Text -> Maybe Text -> RepoSpec -> Channel -> Handler ()