fixed init

This commit is contained in:
Yann Esposito (Yogsototh) 2018-09-02 09:14:23 +02:00
parent 8ca2ed83a7
commit ee7fe89d12
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
4 changed files with 24 additions and 13 deletions

View file

@ -21,5 +21,5 @@ import GPM.Helpers (debug_)
init :: IO ()
init = do
echo "* wiki.org"
output "wiki.org" $(embedStringFile "templates/wiki.org")
writeFile "wiki.org" $(embedStringFile "templates/wiki.org")
debug_ "git add wiki.org"

View file

@ -11,13 +11,15 @@ module GPM.Init
(init)
where
import Protolude
import Protolude hiding (die,fold)
import Turtle
import GPM.Helpers (debug_)
import qualified GPM.Docs as Docs
import qualified GPM.Issue as Issue
import qualified GPM.Review as Review
import qualified Control.Foldl as Fold
import qualified GPM.Docs as Docs
import GPM.Helpers (debug_)
import qualified GPM.Issue as Issue
import qualified GPM.Review as Review
-- | Init a repository with a new empty branch named @gpm@
init :: IO ()
@ -32,9 +34,14 @@ init = do
-- | Create a new empty branch, fail if the branch already exists
mkNewEmptyBranch :: Text -> IO ()
mkNewEmptyBranch br = do
putText $ "create a new branch " <> br <> " (be sure the branch " <> br <> " doesn't already exists)"
debug_ $ "git checkout --orphan " <> br
echo "cleanup the branch"
debug_ "git rm --cached -r ."
mkNewEmptyBranch br = sh $ do
clean <- fold (inshell "git status --porcelain" empty) Fold.null
if clean
then liftIO $ do
putText $ "create a new branch " <> br <> " (be sure the branch " <> br <> " doesn't already exists)"
debug_ $ "git checkout --orphan " <> br
echo "cleanup the branch"
debug_ "git rm --cached -r ."
debug_ "git clean -fd"
else die "Please take care of pending modification and untracked files (you can use git stash --all)"

View file

@ -172,5 +172,9 @@ gatherNewIssueInfos iss = do
init :: IO ()
init = do
echo "* issue.org"
output "issues.org" $(embedStringFile "templates/issues.org")
writeFile "issues.org" $(embedStringFile "templates/issues.org")
debug_ "git add issues.org"
mktree "templates"
writeFile "templates/new-issue.org" $(embedStringFile "templates/new-issue.org")
debug_ "git add templates"

View file

@ -36,7 +36,7 @@ init = do
let fic = "reviews" </> "write-contributing-yogsototh.org"
mktree "reviews"
putText $ format ("* "%fp) fic
output fic $(embedStringFile "templates/review.org")
writeFile (toS (format fp fic)) $(embedStringFile "templates/review.org")
debug_ "git add reviews"