mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Creates README.md even if description is empty.
This commit is contained in:
@@ -26,11 +26,8 @@ class CreateRepositoryServlet extends ScalatraServlet with ServletBase {
|
|||||||
val repositoryName = params("name")
|
val repositoryName = params("name")
|
||||||
val description = params("description")
|
val description = params("description")
|
||||||
|
|
||||||
val dir = getRepositoryDir(LoginUser, repositoryName)
|
val gitdir = getRepositoryDir(LoginUser, repositoryName)
|
||||||
val repository = new RepositoryBuilder()
|
val repository = new RepositoryBuilder().setGitDir(gitdir).setBare.build
|
||||||
.setGitDir(dir)
|
|
||||||
.setBare
|
|
||||||
.build
|
|
||||||
|
|
||||||
repository.create
|
repository.create
|
||||||
|
|
||||||
@@ -38,23 +35,29 @@ class CreateRepositoryServlet extends ScalatraServlet with ServletBase {
|
|||||||
config.setBoolean("http", null, "receivepack", true)
|
config.setBoolean("http", null, "receivepack", true)
|
||||||
config.save
|
config.save
|
||||||
|
|
||||||
if(description.nonEmpty){
|
val tmpdir = getInitRepositoryDir(LoginUser, repositoryName)
|
||||||
val tmpdir = getInitRepositoryDir(LoginUser, repositoryName)
|
try {
|
||||||
Git.cloneRepository.setURI(dir.toURI.toString).setDirectory(tmpdir).call
|
// Clone the repository
|
||||||
|
Git.cloneRepository.setURI(gitdir.toURI.toString).setDirectory(tmpdir).call
|
||||||
|
|
||||||
// Create README.md
|
// Create README.md
|
||||||
val readme = new File(tmpdir, "README.md")
|
val readme = new File(tmpdir, "README.md")
|
||||||
FileUtils.writeStringToFile(readme,
|
|
||||||
repositoryName + "\n===============\n\n" + description, "UTF-8")
|
FileUtils.writeStringToFile(readme, if(description.nonEmpty){
|
||||||
|
repositoryName + "\n===============\n\n" + description
|
||||||
|
} else {
|
||||||
|
repositoryName + "\n===============\n"
|
||||||
|
}, "UTF-8")
|
||||||
|
|
||||||
val git = Git.open(tmpdir)
|
val git = Git.open(tmpdir)
|
||||||
git.add.addFilepattern("README.md").call
|
git.add.addFilepattern("README.md").call
|
||||||
git.commit.setMessage("Initial commit").call
|
git.commit.setMessage("Initial commit").call
|
||||||
git.push.call
|
git.push.call
|
||||||
|
|
||||||
|
} finally {
|
||||||
FileUtils.deleteDirectory(tmpdir)
|
FileUtils.deleteDirectory(tmpdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
redirect("/%s/%s".format(LoginUser, repositoryName))
|
redirect("/%s/%s".format(LoginUser, repositoryName))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user