mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 23:15:49 +01:00
Improve repository creation to not use the working repository.
This commit is contained in:
@@ -56,15 +56,6 @@ object Directory {
|
||||
def getDownloadWorkDir(owner: String, repository: String, sessionId: String): File =
|
||||
new File(getTemporaryDir(owner, repository), s"download/${sessionId}")
|
||||
|
||||
/**
|
||||
* Temporary directory which is used in the repository creation.
|
||||
*
|
||||
* GitBucket generates initial repository contents in this directory and push them.
|
||||
* This directory is removed after the repository creation.
|
||||
*/
|
||||
def getInitRepositoryDir(owner: String, repository: String): File =
|
||||
new File(getTemporaryDir(owner, repository), "init")
|
||||
|
||||
/**
|
||||
* Substance directory of the wiki repository.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.eclipse.jgit.errors.MissingObjectException
|
||||
import java.util.Date
|
||||
import org.eclipse.jgit.api.errors.NoHeadException
|
||||
import service.RepositoryService
|
||||
import org.eclipse.jgit.dircache.DirCacheEntry
|
||||
|
||||
/**
|
||||
* Provides complex JGit operations.
|
||||
@@ -464,4 +465,32 @@ object JGitUtil {
|
||||
}.find(_._1 != null)
|
||||
}
|
||||
|
||||
def createDirCacheEntry(path: String, mode: FileMode, objectId: ObjectId): DirCacheEntry = {
|
||||
val entry = new DirCacheEntry(path)
|
||||
entry.setFileMode(mode)
|
||||
entry.setObjectId(objectId)
|
||||
entry
|
||||
}
|
||||
|
||||
def createNewCommit(git: Git, inserter: ObjectInserter, headId: AnyObjectId, treeId: AnyObjectId,
|
||||
fullName: String, mailAddress: String, message: String): String = {
|
||||
val newCommit = new CommitBuilder()
|
||||
newCommit.setCommitter(new PersonIdent(fullName, mailAddress))
|
||||
newCommit.setAuthor(new PersonIdent(fullName, mailAddress))
|
||||
newCommit.setMessage(message)
|
||||
if(headId != null){
|
||||
newCommit.setParentIds(List(headId).asJava)
|
||||
}
|
||||
newCommit.setTreeId(treeId)
|
||||
|
||||
val newHeadId = inserter.insert(newCommit)
|
||||
inserter.flush()
|
||||
|
||||
val refUpdate = git.getRepository.updateRef(Constants.HEAD)
|
||||
refUpdate.setNewObjectId(newHeadId)
|
||||
refUpdate.update()
|
||||
|
||||
newHeadId.getName
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user