diff --git a/src/GPM/Docs.hs b/src/GPM/Docs.hs index d4631fe..73460d6 100644 --- a/src/GPM/Docs.hs +++ b/src/GPM/Docs.hs @@ -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" diff --git a/src/GPM/Init.hs b/src/GPM/Init.hs index 3e911df..564cde6 100644 --- a/src/GPM/Init.hs +++ b/src/GPM/Init.hs @@ -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)" diff --git a/src/GPM/Issue.hs b/src/GPM/Issue.hs index 22694b3..73f98d2 100644 --- a/src/GPM/Issue.hs +++ b/src/GPM/Issue.hs @@ -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" diff --git a/src/GPM/Review.hs b/src/GPM/Review.hs index 025f057..518b26b 100644 --- a/src/GPM/Review.hs +++ b/src/GPM/Review.hs @@ -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"