mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-12 16:35:52 +01:00
Add new initialize option as git commit -m "..." --allow-empty"
This commit is contained in:
@@ -89,23 +89,26 @@ trait RepositoryCreationService {
|
|||||||
val gitdir = getRepositoryDir(owner, name)
|
val gitdir = getRepositoryDir(owner, name)
|
||||||
JGitUtil.initRepository(gitdir)
|
JGitUtil.initRepository(gitdir)
|
||||||
|
|
||||||
if (initOption == "README") {
|
if (initOption == "README" || initOption == "EMPTY_COMMIT") {
|
||||||
using(Git.open(gitdir)) { git =>
|
using(Git.open(gitdir)) { git =>
|
||||||
val builder = DirCache.newInCore.builder()
|
val builder = DirCache.newInCore.builder()
|
||||||
val inserter = git.getRepository.newObjectInserter()
|
val inserter = git.getRepository.newObjectInserter()
|
||||||
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
||||||
val content = if (description.nonEmpty) {
|
|
||||||
name + "\n" +
|
|
||||||
"===============\n" +
|
|
||||||
"\n" +
|
|
||||||
description.get
|
|
||||||
} else {
|
|
||||||
name + "\n" +
|
|
||||||
"===============\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.add(JGitUtil.createDirCacheEntry("README.md", FileMode.REGULAR_FILE,
|
if (initOption == "README") {
|
||||||
inserter.insert(Constants.OBJ_BLOB, content.getBytes("UTF-8"))))
|
val content = if (description.nonEmpty) {
|
||||||
|
name + "\n" +
|
||||||
|
"===============\n" +
|
||||||
|
"\n" +
|
||||||
|
description.get
|
||||||
|
} else {
|
||||||
|
name + "\n" +
|
||||||
|
"===============\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.add(JGitUtil.createDirCacheEntry("README.md", FileMode.REGULAR_FILE,
|
||||||
|
inserter.insert(Constants.OBJ_BLOB, content.getBytes("UTF-8"))))
|
||||||
|
}
|
||||||
builder.finish()
|
builder.finish()
|
||||||
|
|
||||||
JGitUtil.createNewCommit(git, inserter, headId, builder.getDirCache.writeTree(inserter),
|
JGitUtil.createNewCommit(git, inserter, headId, builder.getDirCache.writeTree(inserter),
|
||||||
|
|||||||
@@ -65,6 +65,13 @@ isCreateRepoOptionPublic: Boolean)(implicit context: gitbucket.core.controller.C
|
|||||||
Create an empty repository. You have to initialize by yourself initially.
|
Create an empty repository. You have to initialize by yourself initially.
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="radio">
|
||||||
|
<input type="radio" name="initOption" value="EMPTY_COMMIT"/>
|
||||||
|
<span class="strong">Initialize this repository with an empty commit</span>
|
||||||
|
<div class="normal muted">
|
||||||
|
Create an empty repository with empty commit. You can clone the repository immediately.
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="initOption" value="README"/>
|
<input type="radio" name="initOption" value="README"/>
|
||||||
<span class="strong">Initialize this repository with a README</span>
|
<span class="strong">Initialize this repository with a README</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user