diff --git a/Handler/Shared.hs b/Handler/Shared.hs index 159018d..7c5fa1d 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -122,11 +122,12 @@ cloneRepo repoCloningSpec chan = do let url = repoSpecUrl $ cloningSpecRepo repoCloningSpec let branch = repoSpecBranch $ cloningSpecRepo repoCloningSpec maybeRepo <- runDB $ getBy $ UniqueUrlBranch url branch + userId <- requireAuthId case maybeRepo of Just _ -> do err chan "Repo already there" return Nothing - Nothing -> cloneRepo' repoCloningSpec chan + Nothing -> cloneRepo' userId repoCloningSpec chan updateRepo :: Key Repo -> Channel -> Handler Bool updateRepo repoId chan = do @@ -172,8 +173,8 @@ getLastCommitMessage repoDir chan = do ExitSuccess -> Just out ExitFailure _ -> Nothing -cloneRepo' :: RepoCloningSpec -> Channel -> Handler (Maybe (Key Repo)) -cloneRepo' repoCloningSpec chan = do +cloneRepo' :: UserId -> RepoCloningSpec -> Channel -> Handler (Maybe (Key Repo)) +cloneRepo' userId repoCloningSpec chan = do let url = repoSpecUrl $ cloningSpecRepo repoCloningSpec msg chan $ concat ["Preparing to clone repo ", url] msg chan "Cloning..." @@ -186,7 +187,6 @@ cloneRepo' repoCloningSpec chan = do maybeHeadCommit <- getHeadCommit tmpRepoDir chan case maybeHeadCommit of Just commitRaw -> do - userId <- requireAuthId time <- liftIO getCurrentTime repoId <- runDB $ insert $ Repo { repoUrl=url, diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 506fcff..5cd58af 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -226,7 +226,7 @@ trigger userId challengeName url mBranch = do doCreateSubmission :: UserId -> Key Challenge -> Maybe Text -> Maybe Text -> RepoSpec -> Channel -> Handler () doCreateSubmission userId challengeId mDescription mTags repoSpec chan = do - maybeRepoKey <- getSubmissionRepo challengeId repoSpec chan + maybeRepoKey <- getSubmissionRepo userId challengeId repoSpec chan case maybeRepoKey of Just repoId -> do repo <- runDB $ get404 repoId @@ -445,8 +445,8 @@ rawEval challengeDir metric repoDir name outF = Import.try (runGEvalGetOptions [ "--out-file", outF, "--test-name", (T.unpack name)]) -getSubmissionRepo :: Key Challenge -> RepoSpec -> Channel -> Handler (Maybe (Key Repo)) -getSubmissionRepo challengeId repoSpec chan = do +getSubmissionRepo :: UserId -> Key Challenge -> RepoSpec -> Channel -> Handler (Maybe (Key Repo)) +getSubmissionRepo userId challengeId repoSpec chan = do let url = repoSpecUrl repoSpec let branch = repoSpecBranch repoSpec let gitAnnexRemote = repoSpecGitAnnexRemote repoSpec @@ -482,7 +482,7 @@ getSubmissionRepo challengeId repoSpec chan = do repoSpecGitAnnexRemote = Nothing } } - cloneRepo' repoCloningSpec chan + cloneRepo' userId repoCloningSpec chan checkRepoAvailibility :: Key Challenge -> Key Repo -> Channel -> Handler Bool checkRepoAvailibility challengeId repoId chan = do diff --git a/templates/query-result.hamlet b/templates/query-result.hamlet index 3b5d858..65abef5 100644 --- a/templates/query-result.hamlet +++ b/templates/query-result.hamlet @@ -2,8 +2,9 @@
#{submissionDescription $ fsiSubmission submission}
#{submitter}
#{stamp} -
taken from: #{repoUrl $ fsiRepo submission} / branch #{repoBranch $ fsiRepo submission} +
taken from: #{repoUrl $ fsiRepo submission} / branch #{repoBranch $ fsiRepo submission} $if submissionIsPublic $ fsiSubmission submission -
publicly available at: #{publicSubmissionRepo} / branch #{publicSubmissionBranch} +
publicly available at: #{publicSubmissionRepo} / branch #{publicSubmissionBranch}
browsable at: #{browsableUrl} +
to get it run: git clone #{publicSubmissionRepo} -b #{publicSubmissionBranch}