on master help sign in
Purge more unchecked exceptions, fixing rollback
commit21fde40dc61b32830f57838e7ebd67cd7363fd50 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateWed 17 Oct 2018, 15:07 (8 years ago) parent88a153b
2 files changed+13−14
lib/command/src/Obelisk/Command/Thunk.hs+5−3 lib/command/src/Obelisk/Command/Utils.hs+8−11
lib/command/src/Obelisk/Command/Thunk.hs+5−3
@@ -698,10 +698,12 @@ getThunkPtr' checkClean thunkDir = do
698698 (flip map (Map.toList nonGood) $ \(branch, (upstream, (ahead, behind))) -> mconcat
699699 [" ", branch, " ahead: ", T.pack (show ahead), " behind: ", T.pack (show behind), " remote branch ", upstream]) ++
700700 [ ""
701− , "Please push these upstream and try again."
701+ , "Please push these upstream and try again. (Or just fetch, if they are somehow \
702+ \ pushed but this repo's remote tracking branches don't know it.)"
702703 ]
703704
704705 -- We assume it's safe to pack the thunk at this point
706+ putLog Informational $ "All changes safe in git remotes. OK to pack thunk."
705707
706708 -- Get current branch ``
707709 mCurrentBranch <- listToMaybe
@@ -840,7 +842,7 @@ gitThunkRev s commit = do
840842 failWith $ "obelisk currently only supports "
841843 <> T.intercalate ", " protocols <> " protocols for non-GitHub remotes"
842844 hash <- nixPrefetchGit u commit $ _gitSource_fetchSubmodules s
843− putLog Debug $ "Nix sha256 is " <> hash
845+ putLog Informational $ "Nix sha256 is " <> hash
844846 pure $ ThunkRev
845847 { _thunkRev_commit = commitNameToRef (N commit)
846848 , _thunkRev_nixSha256 = hash
@@ -864,7 +866,7 @@ gitGetCommitBranch uri mbranch = withExitFailMessage ("Failure for git remote "
864866 pure b
865867 Just b -> pure b
866868 commit <- rethrowE $ gitLookupCommitForRef bothMaps (GitRef_Branch branch)
867− putLog Debug $ "Latest commit in branch " <> branch
869+ putLog Informational $ "Latest commit in branch " <> branch
868870 <> " from remote repo " <> uriMsg
869871 <> " is " <> commit
870872 pure (branch, commit)
lib/command/src/Obelisk/Command/Utils.hs+8−11
@@ -131,7 +131,8 @@ gitLsRemote repository mRef = do
131131 pure maps
132132
133133lexeme :: Parsec Void Text a -> Parsec Void Text a
134−lexeme = ML.lexeme space
134+lexeme = ML.lexeme $ void $ MP.takeWhileP (Just "within-line white space") $
135+ flip elem [' ', '\t']
135136
136137-- $ git ls-remote --symref git@github.com:obsidiansystems/obelisk.git HEAD
137138-- ref: refs/heads/master HEAD
@@ -141,19 +142,15 @@ parseLsRemote =
141142 many ((fmap Left (try parseRef) <|> fmap Right parseCommit) <* try MP.eol) <* MP.eof
142143 where
143144 parseRef :: Parsec Void Text (GitRef, GitRef)
144− parseRef = do
145+ parseRef = MP.label "ref and symbolic ref" $ do
145146 _ <- lexeme "ref:"
146− ref <- lexeme $ MP.takeWhileP (Just "ref")
147− $ not . isSpace
148− symbolicRef <- lexeme $ MP.takeWhileP (Just "symbolic ref")
149− $ not . isSpace
147+ ref <- lexeme $ MP.takeWhileP (Just "ref") $ not . isSpace
148+ symbolicRef <- lexeme $ MP.takeWhileP (Just "symbolic ref") $ not . isSpace
150149 return (toGitRef symbolicRef, toGitRef ref)
151150 parseCommit :: Parsec Void Text (GitRef, CommitId)
152− parseCommit = do
153− commitId <- lexeme $ MP.takeWhileP (Just "commit id")
154− $ not . isSpace
155− ref <- lexeme $ MP.takeWhileP (Just "ref")
156− $ not . isSpace
151+ parseCommit = MP.label "commit and ref" $ do
152+ commitId <- lexeme $ MP.takeWhileP (Just "commit id") $ not . isSpace
153+ ref <- lexeme $ MP.takeWhileP (Just "ref") $ not . isSpace
157154 return (toGitRef ref, commitId)
158155
159156data GitRef