summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2013-05-27 12:00:22 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2013-05-27 12:00:22 +0100
commit09fb03e476f6b6c111ed3b8bd7d6d0911ab94f4f (patch)
tree749e1c7c0b524aa326598cebaf55f33acd95a820
parentca317bc29a67c99e8898a426038d900c458e877e (diff)
downloadgitano-09fb03e476f6b6c111ed3b8bd7d6d0911ab94f4f.tar.bz2
REPOSITORY: Add set_readme method.
Add a set_readme method to gitano.repository so that we can programmatically change the README.
-rw-r--r--lib/gitano/repository.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitano/repository.lua b/lib/gitano/repository.lua
index 39ed21b..371fb51 100644
--- a/lib/gitano/repository.lua
+++ b/lib/gitano/repository.lua
@@ -428,6 +428,18 @@ function repo_method:set_description(newdesc)
return true
end
+function repo_method:set_readme(newreadme)
+ local oldreadme = self.readme_mdwn
+ self.readme_mdwn = newreadme
+ local ok, msg = self:save_admin("Changing readme")
+ if not ok then
+ self.readme_mdwn = oldreadme
+ return nil, msg
+ end
+ log.state("<" .. self.name .. "> Changed readme")
+ return true
+end
+
function repo_method:set_head(newhead)
if not newhead:match("^refs/") then
newhead = "refs/heads/" .. newhead
@@ -571,6 +583,14 @@ function repo_method:save_admin(reason, username)
flat_tree["project.conf"] = conf_blob
+ if self.readme_mdwn then
+ local readme_blob, msg = gall.object.create(self.git, "blob", self.readme_mdwn)
+ if not readme_blob then
+ return nil, msg
+ end
+ flat_tree["README.mdwn"] = readme_blob
+ end
+
local tree, msg = gall.tree.create(self.git, flat_tree)
if not tree then
return nil, msg