hook handling
This commit is contained in:
parent
a79af4e822
commit
39070e1078
4 changed files with 56 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: 2181d6cb75bcd17dab9a58fcfa594141af68c4c3e34050da6ce0beeb47bb7642
|
||||
-- hash: 04bfdb9ffa855881f6cd6cc09bf3b494a2107ded6cc33c41699546a12526099e
|
||||
|
||||
name: gpm
|
||||
version: 0.1.0.0
|
||||
|
@ -24,6 +24,7 @@ library
|
|||
GPM
|
||||
GPM.Docs
|
||||
GPM.Helpers
|
||||
GPM.Hooks
|
||||
GPM.Init
|
||||
GPM.Issue
|
||||
GPM.Review
|
||||
|
|
|
@ -14,6 +14,7 @@ import Turtle
|
|||
|
||||
|
||||
import GPM.Helpers (inGPM)
|
||||
import qualified GPM.Hooks as Hooks
|
||||
import qualified GPM.Init as Init
|
||||
import qualified GPM.Issue as Issue
|
||||
import qualified GPM.Review as Review
|
||||
|
@ -27,11 +28,13 @@ gpm = do
|
|||
NewIssue issueOpt -> inGPM (Issue.handleNewIssue issueOpt)
|
||||
Review reviewCmd -> inGPM (Review.handleReview reviewCmd)
|
||||
Serve serveCmd -> inGPM (Serve.handleServe serveCmd)
|
||||
Hooks hooksCmd -> inGPM (Hooks.handleHooks hooksCmd)
|
||||
|
||||
data Command = Init
|
||||
| NewIssue Issue.IssueOptions
|
||||
| Review Review.ReviewCommand
|
||||
| Serve Serve.ServeCommand
|
||||
| Hooks Hooks.HooksCommand
|
||||
|
||||
parser :: Parser Command
|
||||
parser = subcommand "init" "Initialize gpm" (pure Init)
|
||||
|
@ -44,3 +47,6 @@ parser = subcommand "init" "Initialize gpm" (pure Init)
|
|||
<|> Serve <$> subcommand "serve"
|
||||
"Serve the git to the web"
|
||||
Serve.parseServeCommand
|
||||
<|> Hooks <$> subcommand "hooks"
|
||||
"Handle hooks for this git repository"
|
||||
Hooks.parseHooksCommand
|
||||
|
|
46
src/GPM/Hooks.hs
Normal file
46
src/GPM/Hooks.hs
Normal file
|
@ -0,0 +1,46 @@
|
|||
{-# LANGUAGE ApplicativeDo #-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
{-|
|
||||
module : GPM.Helpers
|
||||
Description : GPM helper functions
|
||||
License : Public Domain
|
||||
Maintainer : yann.esposito@gmail.com
|
||||
-}
|
||||
module GPM.Hooks
|
||||
( init
|
||||
, handleHooks
|
||||
, parseHooksCommand
|
||||
, HooksCommand(..)
|
||||
)
|
||||
where
|
||||
|
||||
import Protolude hiding ((%))
|
||||
import Turtle
|
||||
|
||||
import GPM.Helpers
|
||||
|
||||
data HooksCommand = SyncHooks
|
||||
|
||||
parseHooksCommand :: Parser HooksCommand
|
||||
parseHooksCommand = subcommand "sync" "Synchronize hooks from gpm branch" (pure SyncHooks)
|
||||
|
||||
-- | Init a hook directory with the git hooks
|
||||
init :: IO ()
|
||||
init = do
|
||||
green "* hooks/"
|
||||
putText " Copyings default hooks into the hooks directory"
|
||||
let hooksDir = "hooks"
|
||||
cptree (".git" </> "hooks") hooksDir
|
||||
debug_ (toS (format ("git add "%fp) hooksDir))
|
||||
|
||||
-- | Handle hooks related commands
|
||||
handleHooks :: HooksCommand -> Text -> IO ()
|
||||
handleHooks SyncHooks _ = do
|
||||
let githooksdir = ".git" </> "hooks"
|
||||
gpmhooksdir = "hooks"
|
||||
putErrText (format (" deleting "%fp) githooksdir)
|
||||
rmtree githooksdir
|
||||
putErrText (format (" cp -r "%fp%" "%fp) gpmhooksdir githooksdir)
|
||||
cptree gpmhooksdir githooksdir
|
|
@ -21,6 +21,7 @@ import GPM.Helpers (debug_, yellow)
|
|||
import qualified GPM.Issue as Issue
|
||||
import qualified GPM.Review as Review
|
||||
import qualified GPM.Serve as Serve
|
||||
import qualified GPM.Hooks as Hooks
|
||||
|
||||
-- | Init a repository with a new empty branch named @gpm@
|
||||
init :: IO ()
|
||||
|
@ -30,6 +31,7 @@ init = do
|
|||
Issue.init
|
||||
Docs.init
|
||||
Review.init
|
||||
Hooks.init
|
||||
Serve.init
|
||||
debug_ "git commit -m 'gpm initialized'"
|
||||
debug_ "git checkout master"
|
||||
|
|
Loading…
Reference in a new issue