when run in uninitialized git repo, do firstrun
My $HOME is in git, let's make it work :)
This commit is contained in:
parent
c70496dc7f
commit
bcf5c81593
2 changed files with 11 additions and 4 deletions
|
@ -16,12 +16,13 @@ import Assistant.Threads.WebApp
|
||||||
import Utility.WebApp
|
import Utility.WebApp
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
import Utility.Daemon (checkDaemon)
|
import Utility.Daemon (checkDaemon)
|
||||||
|
import Init
|
||||||
import qualified Command.Watch
|
import qualified Command.Watch
|
||||||
|
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ noRepo firstRun $
|
def = [oneShot $ noRepo firstRun $ dontCheck repoExists $
|
||||||
withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption] $
|
withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption] $
|
||||||
command "webapp" paramNothing seek "launch webapp"]
|
command "webapp" paramNothing seek "launch webapp"]
|
||||||
|
|
||||||
|
@ -34,14 +35,15 @@ start :: Bool -> Bool -> CommandStart
|
||||||
start foreground stopdaemon = notBareRepo $ do
|
start foreground stopdaemon = notBareRepo $ do
|
||||||
if stopdaemon
|
if stopdaemon
|
||||||
then stopDaemon
|
then stopDaemon
|
||||||
else do
|
else ifM (isInitialized) ( go , liftIO firstRun )
|
||||||
|
stop
|
||||||
|
where
|
||||||
|
go = do
|
||||||
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
||||||
ifM (checkpid <&&> checkshim f) $
|
ifM (checkpid <&&> checkshim f) $
|
||||||
( liftIO $ openBrowser f
|
( liftIO $ openBrowser f
|
||||||
, startDaemon True foreground $ Just openBrowser
|
, startDaemon True foreground $ Just openBrowser
|
||||||
)
|
)
|
||||||
stop
|
|
||||||
where
|
|
||||||
checkpid = do
|
checkpid = do
|
||||||
pidfile <- fromRepo gitAnnexPidFile
|
pidfile <- fromRepo gitAnnexPidFile
|
||||||
liftIO $ isJust <$> checkDaemon pidfile
|
liftIO $ isJust <$> checkDaemon pidfile
|
||||||
|
|
5
Init.hs
5
Init.hs
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
module Init (
|
module Init (
|
||||||
ensureInitialized,
|
ensureInitialized,
|
||||||
|
isInitialized,
|
||||||
initialize,
|
initialize,
|
||||||
uninitialize
|
uninitialize
|
||||||
) where
|
) where
|
||||||
|
@ -45,6 +46,10 @@ ensureInitialized = getVersion >>= maybe needsinit checkVersion
|
||||||
, error "First run: git-annex init"
|
, error "First run: git-annex init"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
{- Checks if a repository is initialized. Does not check version for ugrade. -}
|
||||||
|
isInitialized :: Annex Bool
|
||||||
|
isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersion
|
||||||
|
|
||||||
{- set up a git pre-commit hook, if one is not already present -}
|
{- set up a git pre-commit hook, if one is not already present -}
|
||||||
gitPreCommitHookWrite :: Annex ()
|
gitPreCommitHookWrite :: Annex ()
|
||||||
gitPreCommitHookWrite = unlessBare $ do
|
gitPreCommitHookWrite = unlessBare $ do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue