From 3758d1f5ad6371a35aebdbed8ab2dd22169494ea Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Tue, 4 Jul 2017 23:49:56 +0900 Subject: [PATCH 1/4] Fix typo --- .../core/controller/RepositorySettingsController.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index 7c4bc5e00..4ef39e302 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -355,7 +355,7 @@ trait RepositorySettingsControllerBase extends ControllerBase { FileUtils.moveDirectory(dir, getAttachedDir(form.newOwner, repository.name)) } } - // Delere parent directory + // Delete parent directory FileUtil.deleteDirectoryIfEmpty(getRepositoryFilesDir(repository.owner, repository.name)) // Call hooks From ecf3e975180545f302d7969487d5932e39d31ff2 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Tue, 4 Jul 2017 23:51:51 +0900 Subject: [PATCH 2/4] (refs #1631)Copy repository files directory only if it exists --- .../core/controller/AccountController.scala | 17 +++++++++-------- .../scala/gitbucket/core/util/FileUtil.scala | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index c95f4fc4d..6e61b3793 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -598,18 +598,19 @@ trait AccountControllerBase extends AccountManagementControllerBase { // clone repository actually JGitUtil.cloneRepository( getRepositoryDir(repository.owner, repository.name), - getRepositoryDir(accountName, repository.name)) + FileUtil.deleteIfExists(getRepositoryDir(accountName, repository.name))) // Create Wiki repository - JGitUtil.cloneRepository( - getWikiRepositoryDir(repository.owner, repository.name), - getWikiRepositoryDir(accountName, repository.name)) + JGitUtil.cloneRepository(getWikiRepositoryDir(repository.owner, repository.name), + FileUtil.deleteIfExists(getWikiRepositoryDir(accountName, repository.name))) // Copy files - FileUtils.copyDirectory( - Directory.getRepositoryFilesDir(repository.owner, repository.name), - Directory.getRepositoryFilesDir(accountName, repository.name) - ) + val repositoryFilesDir = getRepositoryFilesDir(repository.owner, repository.name) + if(repositoryFilesDir.exists){ + FileUtils.copyDirectory( + repositoryFilesDir, + FileUtil.deleteIfExists(getRepositoryFilesDir(accountName, repository.name))) + } // Record activity recordForkActivity(repository.owner, repository.name, loginUserName, accountName) diff --git a/src/main/scala/gitbucket/core/util/FileUtil.scala b/src/main/scala/gitbucket/core/util/FileUtil.scala index 4f2a21d8e..e31dd6bb3 100644 --- a/src/main/scala/gitbucket/core/util/FileUtil.scala +++ b/src/main/scala/gitbucket/core/util/FileUtil.scala @@ -68,9 +68,24 @@ object FileUtil { def readableSize(size: Long): String = FileUtils.byteCountToDisplaySize(size) + /** + * Delete the given directory if it's empty. + * Do nothing if the given File is not a directory or not empty. + */ def deleteDirectoryIfEmpty(dir: File): Unit = { if(dir.isDirectory() && dir.list().isEmpty) { FileUtils.deleteDirectory(dir) } } + + /** + * Delete file or directory forcibly. + */ + def deleteIfExists(file: java.io.File): java.io.File = { + if(file.exists){ + FileUtils.forceDelete(file) + } + file + } + } From d80774d8d06e1219c861e42f3f816bf218b96301 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 5 Jul 2017 00:01:33 +0900 Subject: [PATCH 3/4] Release 4.14.1 --- README.md | 6 ++++-- build.sbt | 2 +- src/main/scala/gitbucket/core/GitBucketCoreModule.scala | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 683e73c28..5bcc953c5 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,13 @@ Support Release Notes ------------- -### 4.14 - 1 Jul 2017 +### 4.14.1 - 4 Jul 2017 +- Bug fix: Possibility of error in forking repository +### 4.14 - 1 Jul 2017 - Support priority in issues and pull requests - Show icons when the sidebar is collapsed -- Support gollumn events in web hook +- Support gollum events in web hook - Support account (user / group) level web hook - Add `--max_file_size` option - Configuration by system property or environment variable diff --git a/build.sbt b/build.sbt index 22e7b81ce..c941cce63 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val Organization = "io.github.gitbucket" val Name = "gitbucket" -val GitBucketVersion = "4.14.0" +val GitBucketVersion = "4.14.1" val ScalatraVersion = "2.5.0" val JettyVersion = "9.3.19.v20170502" diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 8d678b343..b5a2df872 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -38,5 +38,6 @@ object GitBucketCoreModule extends Module("gitbucket-core", new Version("4.14.0", new LiquibaseMigration("update/gitbucket-core_4.14.xml"), new SqlMigration("update/gitbucket-core_4.14.sql") - ) + ), + new Version("4.14.1") ) From 2f634625ea712f1db7716d91747ee4019a6d8433 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 5 Jul 2017 00:21:15 +0900 Subject: [PATCH 4/4] Copy only LFS dir and insert default priorities in forking repository --- .../core/controller/AccountController.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index 6e61b3793..77eaa1a94 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -594,6 +594,8 @@ trait AccountControllerBase extends AccountManagementControllerBase { // Insert default labels insertDefaultLabels(accountName, repository.name) + // Insert default priorities + insertDefaultPriorities(accountName, repository.name) // clone repository actually JGitUtil.cloneRepository( @@ -604,12 +606,10 @@ trait AccountControllerBase extends AccountManagementControllerBase { JGitUtil.cloneRepository(getWikiRepositoryDir(repository.owner, repository.name), FileUtil.deleteIfExists(getWikiRepositoryDir(accountName, repository.name))) - // Copy files - val repositoryFilesDir = getRepositoryFilesDir(repository.owner, repository.name) - if(repositoryFilesDir.exists){ - FileUtils.copyDirectory( - repositoryFilesDir, - FileUtil.deleteIfExists(getRepositoryFilesDir(accountName, repository.name))) + // Copy LFS files + val lfsDir = getLfsDir(repository.owner, repository.name) + if(lfsDir.exists){ + FileUtils.copyDirectory(lfsDir, FileUtil.deleteIfExists(getLfsDir(accountName, repository.name))) } // Record activity