@@ -87,8 +87,6 @@ decideHandOffToProjectOb project = do
87 -- We don't have ambient's ob source code, so locate its hash from the
87 -- We don't have ambient's ob source code, so locate its hash from the
88 -- graph. The last vertex should be it.
88 -- graph. The last vertex should be it.
89 ambientHash <- getLast (_migration_graph m)
89 ambientHash <- getLast (_migration_graph m)
90− unless (hasVertex ambientHash m) $
91− failWith "Ambient ob's hash is not in its own graph"
92 return (m, ambientHash)
90 return (m, ambientHash)
94-- | Return the path to the current ('ambient') obelisk process Nix directory
92-- | Return the path to the current ('ambient') obelisk process Nix directory
@@ -108,11 +106,11 @@ getObeliskBranch project = readThunk (toImplDir project) >>= \case
108 Right (ThunkData_Packed tptr) -> case getThunkGitBranch tptr of
106 Right (ThunkData_Packed tptr) -> case getThunkGitBranch tptr of
109 Just v -> pure v
107 Just v -> pure v
110 Nothing ->
108 Nothing ->
111− failWith "You must specify a git branch to `ob upgrade` as obelisk thunk does not specify any."
109+ failWith "You must run `ob upgrade` with the Git branch specified explicitly, as the project's obelisk thunk does not specify any."
113updateObelisk :: MonadObelisk m => FilePath -> Text -> m Hash
111updateObelisk :: MonadObelisk m => FilePath -> Text -> m Hash
114updateObelisk project gitBranch =
112updateObelisk project gitBranch =
115− withSpinner ("Fetching new Obelisk [" <> gitBranch <> "]") $
113+ withSpinner ("Fetching new obelisk [" <> gitBranch <> "]") $
116 updateThunk (toImplDir project) $ \obImpl -> do
114 updateThunk (toImplDir project) $ \obImpl -> do
117 fromHash <- computeVertexHash obImpl
115 fromHash <- computeVertexHash obImpl
118 callProcessAndLogOutput (Debug, Debug) $
116 callProcessAndLogOutput (Debug, Debug) $
@@ -123,15 +121,15 @@ updateObelisk project gitBranch =
124handOffToNewOb :: MonadObelisk m => FilePath -> Hash -> m ()
122handOffToNewOb :: MonadObelisk m => FilePath -> Hash -> m ()
125handOffToNewOb project fromHash = do
123handOffToNewOb project fromHash = do
126− impl <- withSpinner' "Preparing for handoff" (Just $ ("Handed off to new Obelisk " <>) . T.pack) $
124+ impl <- withSpinner' "Preparing for handoff" (Just $ ("Handed off to new obelisk " <>) . T.pack) $
127 findProjectObeliskCommand project >>= \case
125 findProjectObeliskCommand project >>= \case
128− Nothing -> failWith "Not an Obelisk project"
126+ Nothing -> failWith "Not an obelisk project"
129 Just impl -> pure impl
127 Just impl -> pure impl
130 let opts = ["internal", "migrate", T.unpack fromHash]
128 let opts = ["internal", "migrate", T.unpack fromHash]
131 liftIO $ executeFile impl False ("--no-handoff" : opts) Nothing
129 liftIO $ executeFile impl False ("--no-handoff" : opts) Nothing
133migrateObelisk :: MonadObelisk m => FilePath -> Hash -> m ()
131migrateObelisk :: MonadObelisk m => FilePath -> Hash -> m ()
134−migrateObelisk project fromHash = void $ withSpinner' "Migrating to new Obelisk" (Just id) $ do
132+migrateObelisk project fromHash = void $ withSpinner' "Migrating to new obelisk" (Just id) $ do
135 updateThunk (toImplDir project) $ \obImpl -> revertObImplOnFail obImpl $ do
133 updateThunk (toImplDir project) $ \obImpl -> revertObImplOnFail obImpl $ do
136 toHash <- computeVertexHash obImpl
134 toHash <- computeVertexHash obImpl
137 g <- getMigrationGraph' obImpl MigrationGraph_ObeliskUpgrade >>= \case
135 g <- getMigrationGraph' obImpl MigrationGraph_ObeliskUpgrade >>= \case
@@ -192,18 +190,18 @@ verifyGraph obDir = do
192 withSpinner "Checking graph integrity" $
190 withSpinner "Checking graph integrity" $
193 ensureGraphIntegrity upgradeGraph
191 ensureGraphIntegrity upgradeGraph
194 withSpinner "Checking existence of HEAD vertex" $
192 withSpinner "Checking existence of HEAD vertex" $
195− void $ getHeadVertex obDir -- HEAD vertex must be present.
193+ void $ getHeadVertex obDir
195+-- | Create an edge from HEAD vertex to the hash corresponding to the Git
196+-- working copy. The HEAD vertex must already exist.
197createMigrationEdgeFromHEAD :: MonadObelisk m => FilePath -> m ()
197createMigrationEdgeFromHEAD :: MonadObelisk m => FilePath -> m ()
198createMigrationEdgeFromHEAD obDir = do
198createMigrationEdgeFromHEAD obDir = do
199 headHash <- getHeadVertex obDir
199 headHash <- getHeadVertex obDir
200 wcHash <- getDirectoryHash migrationIgnore obDir
200 wcHash <- getDirectoryHash migrationIgnore obDir
201 if (headHash == wcHash)
201 if (headHash == wcHash)
203− putLog Warning "No migration necessary (working copy has not changed from HEAD)"
203+ putLog Warning "No migration necessary (working copy has the same hash as that of HEAD)"
205− -- TODO: Add `ob internal create-migration --backfill=n` do it for all revisions.
206− -- See the failure condition in getHeadVertex
207 writeEdge (migrationDir obDir) graphNames headHash wcHash >>= \case
205 writeEdge (migrationDir obDir) graphNames headHash wcHash >>= \case
208 Nothing ->
206 Nothing ->
209 putLog Warning "No migration was created"
207 putLog Warning "No migration was created"