aboutsummaryrefslogtreecommitdiff
path: root/Command/Init.hs
blob: fa5725c48f47e9f18c121d8f42fbe4221ece1a56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{- git-annex command
 -
 - Copyright 2010 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

module Command.Init where

import Control.Monad.State (liftIO)
import Control.Monad (when)

import Command
import qualified Annex
import Core
import qualified GitRepo as Git
import UUID
import Version
import Messages

{- Stores description for the repository etc. -}
start :: SubCmdStartString
start description = do
	when (null description) $ error $
		"please specify a description of this repository\n"
	showStart "init" description
	return $ Just $ perform description

perform :: String -> SubCmdPerform
perform description = do
	g <- Annex.gitRepo
	u <- getUUID g
	describeUUID u description
	setVersion
	liftIO $ gitAttributes g
	liftIO $ gitPreCommitHook g
	return $ Just $ cleanup

cleanup :: SubCmdCleanup
cleanup = do
	g <- Annex.gitRepo
	logfile <- uuidLog
	liftIO $ Git.run g ["add", logfile]
	liftIO $ Git.run g ["commit", "-m", "git annex init", logfile]
	return True