summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2018-02-11 14:34:58 -0400
committerJoey Hess2018-02-11 14:34:58 -0400
commit1ea90f1b69e071b3e533f9b33acb2415c6e916ab (patch)
treeff36bb8153ae61f85c264123790c702e901c2ed5
parent0ea2e0b04e0cd541707e70caa1981e2a417bd01d (diff)
add Git.pulled property
This commit was sponsored by Nick Daly on Patreon.
-rw-r--r--debian/changelog6
-rw-r--r--src/Propellor/Property/Git.hs18
2 files changed, 24 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 5d032b4c..178aabdb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+propellor (5.3.2) UNRELEASED; urgency=medium
+
+ * Added Git.pulled.
+
+ -- Joey Hess <id@joeyh.name> Sun, 11 Feb 2018 11:58:04 -0400
+
propellor (5.3.1) unstable; urgency=medium
* Last release mistakenly contained my personal branch not master.
diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs
index 5d7c8b4d..e7dcb80c 100644
--- a/src/Propellor/Property/Git.hs
+++ b/src/Propellor/Property/Git.hs
@@ -61,6 +61,9 @@ type Branch = String
-- it will be recursively deleted first.
--
-- A branch can be specified, to check out.
+--
+-- Does not make subsequent changes be pulled into the repository after
+-- it's cloned.
cloned :: User -> RepoUrl -> FilePath -> Maybe Branch -> Property DebianLike
cloned owner url dir mbranch = check originurl go
`requires` installed
@@ -95,11 +98,26 @@ cloned owner url dir mbranch = check originurl go
, Just "git update-server-info"
]
+-- | Specified git repository is cloned to the specified directory,
+-- and any new commits are pulled into it each time this property runs.
+pulled :: User -> RepoUrl -> FilePath -> Maybe Branch -> Property DebianLike
+pulled owner url dir mbranch = go
+ `requires` cloned owner url dir mbranch
+ `describe` desc
+ where
+ desc = "git pulled " ++ url ++ " to " ++ dir
+ go = userScriptProperty owner
+ [ "cd " ++ shellEscape dir
+ , "git pull"
+ ]
+ `changesFile` (dir </> ".git" </> "FETCH_HEAD")
+
isGitDir :: FilePath -> IO Bool
isGitDir dir = isNothing <$> catchMaybeIO (readProcess "git" ["rev-parse", "--resolve-git-dir", dir])
data GitShared = Shared Group | SharedAll | NotShared
+-- | Sets up a new, empty bare git repository.
bareRepo :: FilePath -> User -> GitShared -> Property UnixLike
bareRepo repo user gitshared = check (isRepo repo) $ propertyList ("git repo: " ++ repo) $ toProps $
dirExists repo : case gitshared of