From d224fc1c5ff54ef2326e27681963397217bf9784 Mon Sep 17 00:00:00 2001 From: KOUNOIKE Yuusuke Date: Mon, 23 Apr 2018 00:10:49 +0900 Subject: [PATCH 01/17] add tag on commit. close #1265 --- .../RepositoryViewerController.scala | 23 ++++++++++++++++- .../scala/gitbucket/core/util/JGitUtil.scala | 25 ++++++++++++++----- .../gitbucket/core/repo/commit.scala.html | 25 ++++++++++++++++--- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 3da3594f9..e8e967ddd 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -515,7 +515,9 @@ trait RepositoryViewerControllerBase extends ControllerBase { repository, diffs, oldCommitId, - hasDeveloperRole(repository.owner, repository.name, context.loginAccount) + hasDeveloperRole(repository.owner, repository.name, context.loginAccount), + flash.get("info"), + flash.get("error") ) } } @@ -730,6 +732,25 @@ trait RepositoryViewerControllerBase extends ControllerBase { html.branches(branches, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), repository) }) + /** + * Creates a tag + */ + post("/:owner/:repository/tags")(writableUsersOnly { repository => + val tagName = params.getOrElse("name", halt(400)) + val message = params.getOrElse("message", halt(400)) + val commitId = params.getOrElse("commit", halt(400)) + using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git => + JGitUtil.createTag(git, tagName, message, commitId) + } match { + case Right(message) => + flash += "info" -> message + redirect(s"/${repository.owner}/${repository.name}/commit/${commitId}") + case Left(message) => + flash += "error" -> message + redirect(s"/${repository.owner}/${repository.name}/commit/${commitId}") + } + }) + /** * Creates a branch. */ diff --git a/src/main/scala/gitbucket/core/util/JGitUtil.scala b/src/main/scala/gitbucket/core/util/JGitUtil.scala index bb33431f6..0803150c3 100644 --- a/src/main/scala/gitbucket/core/util/JGitUtil.scala +++ b/src/main/scala/gitbucket/core/util/JGitUtil.scala @@ -23,12 +23,7 @@ import java.util.concurrent.TimeUnit import java.util.function.Consumer import org.cache2k.Cache2kBuilder -import org.eclipse.jgit.api.errors.{ - InvalidRefNameException, - JGitInternalException, - NoHeadException, - RefAlreadyExistsException -} +import org.eclipse.jgit.api.errors._ import org.eclipse.jgit.diff.{DiffEntry, DiffFormatter, RawTextComparator} import org.eclipse.jgit.dircache.DirCacheEntry import org.eclipse.jgit.util.io.DisabledOutputStream @@ -816,6 +811,24 @@ object JGitUtil { .find(_._1 != null) } + def createTag(git: Git, name: String, message: String, commitId: String) = { + try { + val objectId: ObjectId = git.getRepository.resolve(commitId) + val walk: RevWalk = new RevWalk(git.getRepository) + val tagCommand = git.tag().setName(name).setObjectId(walk.parseCommit(objectId)) + if (!message.isEmpty) { + tagCommand.setMessage(message) + } + tagCommand.call() + Right("Tag added.") + } catch { + case e: GitAPIException => Left("Sorry, some Git operation error occurs.") + case e: ConcurrentRefUpdateException => Left("Sorry some error occurs.") + case e: InvalidTagNameException => Left("Sorry, that name is invalid.") + case e: NoHeadException => Left("Sorry, this repo doesn't have HEAD reference") + } + } + def createBranch(git: Git, fromBranch: String, newBranch: String) = { try { git.branchCreate().setStartPoint(fromBranch).setName(newBranch).call() diff --git a/src/main/twirl/gitbucket/core/repo/commit.scala.html b/src/main/twirl/gitbucket/core/repo/commit.scala.html index 0658bbf02..62e19ce5f 100644 --- a/src/main/twirl/gitbucket/core/repo/commit.scala.html +++ b/src/main/twirl/gitbucket/core/repo/commit.scala.html @@ -6,16 +6,35 @@ repository: gitbucket.core.service.RepositoryService.RepositoryInfo, diffs: Seq[gitbucket.core.util.JGitUtil.DiffInfo], oldCommitId: Option[String], - hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context) + hasWritePermission: Boolean, + info: Option[Any] = None, + error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @import gitbucket.core.view.helpers.RichHtmlSeq @gitbucket.core.html.main(commit.shortMessage, Some(repository)){ - @gitbucket.core.html.menu("files", repository){ + @gitbucket.core.html.menu("files", repository, None, info, error){
-
+
Browse code + @if(hasWritePermission) { + + + }
@helpers.link(commit.summary, repository)
@if(commit.description.isDefined){ From a02f020626070fbca0ef4959c93dacda19d3e27a Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 18 Jul 2018 10:12:15 +0900 Subject: [PATCH 02/17] Create SunJDK's SSL Provider by reflection --- .../scala/gitbucket/core/util/LDAPUtil.scala | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/scala/gitbucket/core/util/LDAPUtil.scala b/src/main/scala/gitbucket/core/util/LDAPUtil.scala index 9facd51f7..3e21fa4c3 100644 --- a/src/main/scala/gitbucket/core/util/LDAPUtil.scala +++ b/src/main/scala/gitbucket/core/util/LDAPUtil.scala @@ -5,8 +5,11 @@ import SyntaxSugars._ import gitbucket.core.service.SystemSettingsService import gitbucket.core.service.SystemSettingsService.Ldap import com.novell.ldap._ -import java.security.Security +import java.security.{Provider, Security} +import java.util.concurrent.atomic.AtomicReference + import org.slf4j.LoggerFactory + import scala.annotation.tailrec /** @@ -15,10 +18,11 @@ import scala.annotation.tailrec object LDAPUtil { private val LDAP_VERSION: Int = LDAPConnection.LDAP_V3 - private val logger = LoggerFactory.getLogger(getClass().getName()) - private val LDAP_DUMMY_MAL = "@ldap-devnull" + private val logger = LoggerFactory.getLogger(getClass().getName()) + private val provider = new AtomicReference[Provider](null) + /** * Returns true if mail address ends with "@ldap-devnull" */ @@ -120,6 +124,17 @@ object LDAPUtil { }).replaceAll("[^a-zA-Z0-9\\-_.]", "").replaceAll("^[_\\-]", "") } + private def getSslProvider(): Provider = { + val cachedInstance = provider.get() + if(cachedInstance == null){ + val newInstance = Class.forName("com.sun.net.ssl.internal.ssl.Provider").newInstance().asInstanceOf[Provider] + provider.compareAndSet(null, newInstance) + newInstance + } else { + cachedInstance + } + } + private def bind[A]( host: String, port: Int, @@ -132,7 +147,7 @@ object LDAPUtil { )(f: LDAPConnection => Either[String, A]): Either[String, A] = { if (tls) { // Dynamically set Sun as the security provider - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()) + Security.addProvider(getSslProvider()) if (keystore.compareTo("") != 0) { // Dynamically set the property that JSSE uses to identify From d4a9a2b2ee94213fcc23fa69dc7211c4ea0cca9c Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 18 Jul 2018 13:44:59 +0900 Subject: [PATCH 03/17] Format --- src/main/scala/gitbucket/core/util/LDAPUtil.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/gitbucket/core/util/LDAPUtil.scala b/src/main/scala/gitbucket/core/util/LDAPUtil.scala index 3e21fa4c3..a2ec68690 100644 --- a/src/main/scala/gitbucket/core/util/LDAPUtil.scala +++ b/src/main/scala/gitbucket/core/util/LDAPUtil.scala @@ -126,7 +126,7 @@ object LDAPUtil { private def getSslProvider(): Provider = { val cachedInstance = provider.get() - if(cachedInstance == null){ + if (cachedInstance == null) { val newInstance = Class.forName("com.sun.net.ssl.internal.ssl.Provider").newInstance().asInstanceOf[Provider] provider.compareAndSet(null, newInstance) newInstance From 55c973b7605cc68b3a9c0f9f871fa5e12de2cd4d Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 18 Jul 2018 17:18:10 +0900 Subject: [PATCH 04/17] (refs #2097)Fix mouse cursor --- src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html index 9bc67c65d..a7e868539 100644 --- a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html +++ b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html @@ -10,7 +10,7 @@ @if(!status.statuses.isEmpty){
@defining(status.commitStateSummary){ case (summaryState, summary) => - + @helpers.commitStateIcon(summaryState) @helpers.commitStateText(summaryState, pullreq.commitIdTo) — @summary checks From aac232f33e7c6bf9c39a31cbc7f613d9fece8587 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 18 Jul 2018 18:39:08 +0900 Subject: [PATCH 05/17] Separate issues and pull requests search --- .../core/controller/IndexController.scala | 14 ++++++++++++-- .../gitbucket/core/service/IssuesService.scala | 6 ++++-- .../core/service/RepositorySearchService.scala | 10 ++++++---- .../twirl/gitbucket/core/search/issues.scala.html | 11 ++++++----- .../twirl/gitbucket/core/search/menu.scala.html | 7 +++++-- .../twirl/gitbucket/core/search/wiki.scala.html | 4 ++-- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index 7770ccc01..e55386440 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -237,9 +237,19 @@ trait IndexControllerBase extends ControllerBase { } target.toLowerCase match { - case "issue" => + case "issues" => gitbucket.core.search.html.issues( - if (query.nonEmpty) searchIssues(repository.owner, repository.name, query) else Nil, + if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, false) else Nil, + false, + query, + page, + repository + ) + + case "pulls" => + gitbucket.core.search.html.issues( + if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, true) else Nil, + true, query, page, repository diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 05255c4d9..816a5529f 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -630,7 +630,7 @@ trait IssuesService { * @param query the keywords separated by whitespace. * @return issues with comment count and matched content of issue or comment */ - def searchIssuesByKeyword(owner: String, repository: String, query: String)( + def searchIssuesByKeyword(owner: String, repository: String, query: String, pullRequest: Boolean)( implicit s: Session ): List[(Issue, Int, String)] = { //import slick.driver.JdbcDriver.likeEncode @@ -638,7 +638,9 @@ trait IssuesService { // Search Issue val issues = Issues - .filter(_.byRepository(owner, repository)) + .filter { t => + t.byRepository(owner, repository) && t.pullRequest === pullRequest.bind + } .join(IssueOutline) .on { case (t1, t2) => diff --git a/src/main/scala/gitbucket/core/service/RepositorySearchService.scala b/src/main/scala/gitbucket/core/service/RepositorySearchService.scala index 4c5379263..683b97bd1 100644 --- a/src/main/scala/gitbucket/core/service/RepositorySearchService.scala +++ b/src/main/scala/gitbucket/core/service/RepositorySearchService.scala @@ -14,13 +14,15 @@ import gitbucket.core.model.Profile.profile.blockingApi._ trait RepositorySearchService { self: IssuesService => import RepositorySearchService._ - def countIssues(owner: String, repository: String, query: String)(implicit session: Session): Int = - searchIssuesByKeyword(owner, repository, query).length + def countIssues(owner: String, repository: String, query: String, pullRequest: Boolean)( + implicit session: Session + ): Int = + searchIssuesByKeyword(owner, repository, query, pullRequest).length - def searchIssues(owner: String, repository: String, query: String)( + def searchIssues(owner: String, repository: String, query: String, pullRequest: Boolean)( implicit session: Session ): List[IssueSearchResult] = - searchIssuesByKeyword(owner, repository, query).map { + searchIssuesByKeyword(owner, repository, query, pullRequest).map { case (issue, commentCount, content) => IssueSearchResult( issue.issueId, diff --git a/src/main/twirl/gitbucket/core/search/issues.scala.html b/src/main/twirl/gitbucket/core/search/issues.scala.html index 817b47a29..e87a3584e 100644 --- a/src/main/twirl/gitbucket/core/search/issues.scala.html +++ b/src/main/twirl/gitbucket/core/search/issues.scala.html @@ -1,16 +1,17 @@ @(issues: List[gitbucket.core.service.RepositorySearchService.IssueSearchResult], + pullRequest: Boolean, query: String, page: Int, repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @import gitbucket.core.service.RepositorySearchService @gitbucket.core.html.main("Search Results", Some(repository)){ - @gitbucket.core.search.html.menu("issues", query, repository){ + @gitbucket.core.search.html.menu(if(pullRequest) "pulls" else "issues", query, repository){ @if(query.nonEmpty) { @if(issues.isEmpty) { -

We couldn't find any code matching '@query'

+

We couldn't find any @{if(pullRequest) "pull requests" else "issues"} matching '@query'

} else { -

We've found @issues.size @helpers.plural(issues.size, "issue")

+

We've found @issues.size @helpers.plural(issues.size, if(pullRequest) "pull request" else "issue")

} } @issues.drop((page - 1) * RepositorySearchService.IssueLimit).take(RepositorySearchService.IssueLimit).map { issue => @@ -31,6 +32,6 @@
} @gitbucket.core.helper.html.paginator(page, issues.size, RepositorySearchService.IssueLimit, 10, - s"${helpers.url(repository)}/search?q=${helpers.urlEncode(query)}&type=issue") + s"${helpers.url(repository)}/search?q=${helpers.urlEncode(query)}&type=${if(pullRequest) "pulls" else "issues"}") } -} \ No newline at end of file +} diff --git a/src/main/twirl/gitbucket/core/search/menu.scala.html b/src/main/twirl/gitbucket/core/search/menu.scala.html index d3b1d9309..f576b5466 100644 --- a/src/main/twirl/gitbucket/core/search/menu.scala.html +++ b/src/main/twirl/gitbucket/core/search/menu.scala.html @@ -6,7 +6,10 @@ @body -} \ No newline at end of file +} diff --git a/src/main/twirl/gitbucket/core/search/wiki.scala.html b/src/main/twirl/gitbucket/core/search/wiki.scala.html index 234784d3e..56228fd62 100644 --- a/src/main/twirl/gitbucket/core/search/wiki.scala.html +++ b/src/main/twirl/gitbucket/core/search/wiki.scala.html @@ -8,7 +8,7 @@ @gitbucket.core.search.html.menu("wiki", query, repository){ @if(query.nonEmpty) { @if(wikis.isEmpty) { -

We could not find any code matching '@query'

+

We could not find any pages matching '@query'

} else {

We've found @wikis.size @helpers.plural(wikis.size, "page")

} @@ -23,4 +23,4 @@ @gitbucket.core.helper.html.paginator(page, wikis.size, RepositorySearchService.CodeLimit, 10, s"${helpers.url(repository)}/search?q=${helpers.urlEncode(query)}&type=wiki") } -} \ No newline at end of file +} From cb5a5b7b6f16429d84b15a1a25c9fcd6a91bfe54 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 19 Jul 2018 20:02:56 +0900 Subject: [PATCH 06/17] Fix search type parameter --- src/main/twirl/gitbucket/core/issues/list.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/twirl/gitbucket/core/issues/list.scala.html b/src/main/twirl/gitbucket/core/issues/list.scala.html index f36f27400..755be28e3 100644 --- a/src/main/twirl/gitbucket/core/issues/list.scala.html +++ b/src/main/twirl/gitbucket/core/issues/list.scala.html @@ -25,7 +25,7 @@
- + From 403d5afedcd9962ce4d4f5cc47518c683a035e55 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 19 Jul 2018 21:13:13 +0900 Subject: [PATCH 07/17] Display "Closed" label on the search result of issues and pull requests --- .../gitbucket/core/service/IssuesService.scala | 13 +++++++------ .../core/service/RepositorySearchService.scala | 2 ++ .../twirl/gitbucket/core/search/issues.scala.html | 7 ++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 816a5529f..24a056660 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -675,11 +675,12 @@ trait IssuesService { } .filter { case ((t1, t2), t3) => - keywords - .map { query => - t1.content.toLowerCase like (s"%${likeEncode(query)}%", '^') - } - .reduceLeft(_ && _) + t2.pullRequest === pullRequest.bind && + keywords + .map { query => + t1.content.toLowerCase like (s"%${likeEncode(query)}%", '^') + } + .reduceLeft(_ && _) } .map { case ((t1, t2), t3) => @@ -690,7 +691,7 @@ trait IssuesService { .union(comments) .sortBy { case (issue, commentId, _, _) => - issue.issueId -> commentId + issue.issueId.desc -> commentId } .list .splitWith { diff --git a/src/main/scala/gitbucket/core/service/RepositorySearchService.scala b/src/main/scala/gitbucket/core/service/RepositorySearchService.scala index 683b97bd1..a06af1d30 100644 --- a/src/main/scala/gitbucket/core/service/RepositorySearchService.scala +++ b/src/main/scala/gitbucket/core/service/RepositorySearchService.scala @@ -28,6 +28,7 @@ trait RepositorySearchService { self: IssuesService => issue.issueId, issue.isPullRequest, issue.title, + issue.closed, issue.openedUserName, issue.registeredDate, commentCount, @@ -144,6 +145,7 @@ object RepositorySearchService { issueId: Int, isPullRequest: Boolean, title: String, + isClosed: Boolean, openedUserName: String, registeredDate: java.util.Date, commentCount: Int, diff --git a/src/main/twirl/gitbucket/core/search/issues.scala.html b/src/main/twirl/gitbucket/core/search/issues.scala.html index e87a3584e..018c135f5 100644 --- a/src/main/twirl/gitbucket/core/search/issues.scala.html +++ b/src/main/twirl/gitbucket/core/search/issues.scala.html @@ -16,7 +16,12 @@ } @issues.drop((page - 1) * RepositorySearchService.IssueLimit).take(RepositorySearchService.IssueLimit).map { issue =>
-
#@issue.issueId
+
+ @if(issue.isClosed){ + Closed + } + #@issue.issueId +

@issue.title

@if(issue.highlightText.nonEmpty){
@Html(issue.highlightText)
From 3a9f67f862f89f9005c4fa48d7312e6479beffea Mon Sep 17 00:00:00 2001 From: Uli Heller Date: Sat, 21 Jul 2018 18:13:57 +0200 Subject: [PATCH 08/17] mariadb: 2.2.5 -> 2.2.6 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a31963bf9..5d06b1cff 100644 --- a/build.sbt +++ b/build.sbt @@ -47,7 +47,7 @@ libraryDependencies ++= Seq( "com.github.takezoe" %% "blocking-slick-32" % "0.0.10", "com.novell.ldap" % "jldap" % "2009-10-07", "com.h2database" % "h2" % "1.4.196", - "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.5", + "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.6", "org.postgresql" % "postgresql" % "42.1.4", "ch.qos.logback" % "logback-classic" % "1.2.3", "com.zaxxer" % "HikariCP" % "2.7.4", From 8948c05080406b7efd8bab5baee6ce10f6d31862 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sun, 22 Jul 2018 18:45:22 +0900 Subject: [PATCH 09/17] Keep original commitId and lines of pull request comments --- src/main/resources/update/gitbucket-core_4.27.xml | 14 ++++++++++++++ .../scala/gitbucket/core/GitBucketCoreModule.scala | 3 ++- src/main/scala/gitbucket/core/model/Comment.scala | 13 +++++++++++-- .../gitbucket/core/service/CommitsService.scala | 5 ++++- .../core/service/PullRequestService.scala | 8 ++++---- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/update/gitbucket-core_4.27.xml diff --git a/src/main/resources/update/gitbucket-core_4.27.xml b/src/main/resources/update/gitbucket-core_4.27.xml new file mode 100644 index 000000000..b939f53ec --- /dev/null +++ b/src/main/resources/update/gitbucket-core_4.27.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 99b0c6e73..c0345f472 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -55,5 +55,6 @@ object GitBucketCoreModule new Version("4.24.0", new LiquibaseMigration("update/gitbucket-core_4.24.xml")), new Version("4.24.1"), new Version("4.25.0", new LiquibaseMigration("update/gitbucket-core_4.25.xml")), - new Version("4.26.0") + new Version("4.26.0"), + new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml")) ) diff --git a/src/main/scala/gitbucket/core/model/Comment.scala b/src/main/scala/gitbucket/core/model/Comment.scala index 8e5044cbb..9314b2e90 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -54,6 +54,9 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile => val registeredDate = column[java.util.Date]("REGISTERED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE") val issueId = column[Option[Int]]("ISSUE_ID") + val originalCommitId = column[String]("ORIGINAL_COMMIT_ID") + val originalOldLine = column[Option[Int]]("ORIGINAL_OLD_LINE") + val originalNewLine = column[Option[Int]]("ORIGINAL_NEW_LINE") def * = ( userName, @@ -67,7 +70,10 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile => newLine, registeredDate, updatedDate, - issueId + issueId, + originalCommitId, + originalOldLine, + originalNewLine ) <> (CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind @@ -86,7 +92,10 @@ case class CommitComment( newLine: Option[Int], registeredDate: java.util.Date, updatedDate: java.util.Date, - issueId: Option[Int] + issueId: Option[Int], + originalCommitId: String, + originalOldLine: Option[Int], + originalNewLine: Option[Int] ) extends Comment case class CommitComments( diff --git a/src/main/scala/gitbucket/core/service/CommitsService.scala b/src/main/scala/gitbucket/core/service/CommitsService.scala index 8f81b760b..b59c9298c 100644 --- a/src/main/scala/gitbucket/core/service/CommitsService.scala +++ b/src/main/scala/gitbucket/core/service/CommitsService.scala @@ -49,7 +49,10 @@ trait CommitsService { newLine = newLine, registeredDate = currentDate, updatedDate = currentDate, - issueId = issueId + issueId = issueId, + originalCommitId = commitId, + originalOldLine = oldLine, + originalNewLine = newLine ) def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])( diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index c6cde8e13..8612d7452 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -181,9 +181,9 @@ trait PullRequestService { self: IssuesService with CommitsService => // Collect comment positions val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true) .collect { - case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _) => + case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _, _, _, _) => (file, commentId, Right(newLine)) - case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _) => + case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _, _, _, _) => (file, commentId, Left(oldLine)) } .groupBy { case (file, _, _) => file } @@ -348,7 +348,7 @@ trait PullRequestService { self: IssuesService with CommitsService => .groupBy { case x: IssueComment => (Some(x.commentId), None, None, None) case x: CommitComment if x.fileName.isEmpty => (Some(x.commentId), None, None, None) - case x: CommitComment => (None, x.fileName, x.oldLine, x.newLine) + case x: CommitComment => (None, x.fileName, x.originalOldLine, x.originalNewLine) case x => throw new MatchError(x) } .toSeq @@ -366,7 +366,7 @@ trait PullRequestService { self: IssuesService with CommitsService => diff = loadCommitCommentDiff( userName, repositoryName, - comments.head.asInstanceOf[CommitComment].commitId, + comments.head.asInstanceOf[CommitComment].originalCommitId, fileName, oldLine, newLine From bb59cbcb9158c884366f3bfa2c411237d847ac53 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 23 Jul 2018 02:24:45 +0900 Subject: [PATCH 10/17] Fix the file remove page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cancel button didn’t work - Redirection after remove didn’t work - Diff wasn’t displayed at the remove confirmation page --- .../core/controller/RepositoryViewerController.scala | 4 +++- src/main/twirl/gitbucket/core/helper/diff.scala.html | 4 ++-- src/main/twirl/gitbucket/core/repo/delete.scala.html | 6 +++--- src/main/webapp/assets/common/js/gitbucket.js | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 8e4e3d56a..b6b3fb583 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -427,8 +427,10 @@ trait RepositoryViewerControllerBase extends ControllerBase { commit = form.commit ) + println(form.path) + redirect( - s"/${repository.owner}/${repository.name}/tree/${form.branch}${if (form.path.length == 0) "" else form.path}" + s"/${repository.owner}/${repository.name}/tree/${form.branch}${if (form.path.length == 0) "" else "/" + form.path}" ) }) diff --git a/src/main/twirl/gitbucket/core/helper/diff.scala.html b/src/main/twirl/gitbucket/core/helper/diff.scala.html index 2dbe74c49..a3bc93167 100644 --- a/src/main/twirl/gitbucket/core/helper/diff.scala.html +++ b/src/main/twirl/gitbucket/core/helper/diff.scala.html @@ -103,8 +103,8 @@ } else { @if(diff.newContent != None || diff.oldContent != None){
- - + + } else { @if(diff.newIsImage || diff.oldIsImage){
diff --git a/src/main/twirl/gitbucket/core/repo/delete.scala.html b/src/main/twirl/gitbucket/core/repo/delete.scala.html index e4be22212..df3158b16 100644 --- a/src/main/twirl/gitbucket/core/repo/delete.scala.html +++ b/src/main/twirl/gitbucket/core/repo/delete.scala.html @@ -32,8 +32,8 @@
- - + +
@@ -46,7 +46,7 @@
- Cancel + Cancel
diff --git a/src/main/webapp/assets/common/js/gitbucket.js b/src/main/webapp/assets/common/js/gitbucket.js index cd18f3b51..48640e4d4 100644 --- a/src/main/webapp/assets/common/js/gitbucket.js +++ b/src/main/webapp/assets/common/js/gitbucket.js @@ -78,9 +78,9 @@ function displayErrors(data, elem){ function diffUsingJS(oldTextId, newTextId, outputId, viewType, ignoreSpace) { var old = $('#'+oldTextId), head = $('#' + newTextId); var render = new JsDiffRender({ - oldText: old.attr('data-val'), + oldText: old.val(), oldTextName: old.attr('data-file-name'), - newText: head.attr('data-val'), + newText: head.val(), newTextName: head.attr('data-file-name'), ignoreSpace: ignoreSpace, contextSize: 4 From 78fbeb67d46d0202fd164019b522d99fe97fd1db Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 23 Jul 2018 10:57:23 +0900 Subject: [PATCH 11/17] (Closes #2111)Fix comment toggle link on Firefox --- src/main/twirl/gitbucket/core/helper/commitcomments.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/twirl/gitbucket/core/helper/commitcomments.scala.html b/src/main/twirl/gitbucket/core/helper/commitcomments.scala.html index 561e94e2f..bbdd11331 100644 --- a/src/main/twirl/gitbucket/core/helper/commitcomments.scala.html +++ b/src/main/twirl/gitbucket/core/helper/commitcomments.scala.html @@ -7,7 +7,7 @@
@comments.fileName @if(!latestCommitId.contains(comments.comments.head.commitId)) { - + }
From a5e130db0b879bfb7e648fa9c2578f5af0fa1f23 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 23 Jul 2018 13:32:46 +0900 Subject: [PATCH 12/17] Change the create tag form to a dialog --- .../RepositoryViewerController.scala | 32 ++++++++++++++----- .../scala/gitbucket/core/util/JGitUtil.scala | 13 ++++---- .../gitbucket/core/repo/commit.scala.html | 16 +--------- .../twirl/gitbucket/core/repo/tag.scala.html | 26 +++++++++++++++ 4 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src/main/twirl/gitbucket/core/repo/tag.scala.html diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index bcfae94b0..105414904 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -117,6 +117,12 @@ trait RepositoryViewerControllerBase extends ControllerBase { diff: Option[String] ) + case class TagForm( + commitId: String, + tagName: String, + message: Option[String] + ) + val uploadForm = mapping( "branch" -> trim(label("Branch", text(required))), "path" -> trim(label("Path", text())), @@ -153,6 +159,12 @@ trait RepositoryViewerControllerBase extends ControllerBase { "diff" -> optional(text()) )(CommentForm.apply) + val tagForm = mapping( + "commitId" -> trim(label("Commit id", text(required))), + "tagName" -> trim(label("Tag name", text(required))), + "message" -> trim(label("Message", optional(text()))) + )(TagForm.apply) + /** * Returns converted HTML from Markdown for preview. */ @@ -794,21 +806,25 @@ trait RepositoryViewerControllerBase extends ControllerBase { }) /** - * Creates a tag + * Displays the create tag dialog. */ - post("/:owner/:repository/tags")(writableUsersOnly { repository => - val tagName = params.getOrElse("name", halt(400)) - val message = params.getOrElse("message", halt(400)) - val commitId = params.getOrElse("commit", halt(400)) + get("/:owner/:repository/tag/:id")(writableUsersOnly { repository => + html.tag(params("id"), repository) + }) + + /** + * Creates a tag. + */ + post("/:owner/:repository/tag", tagForm)(writableUsersOnly { (form, repository) => using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git => - JGitUtil.createTag(git, tagName, message, commitId) + JGitUtil.createTag(git, form.tagName, form.message, form.commitId) } match { case Right(message) => flash += "info" -> message - redirect(s"/${repository.owner}/${repository.name}/commit/${commitId}") + redirect(s"/${repository.owner}/${repository.name}/commit/${form.commitId}") case Left(message) => flash += "error" -> message - redirect(s"/${repository.owner}/${repository.name}/commit/${commitId}") + redirect(s"/${repository.owner}/${repository.name}/commit/${form.commitId}") } }) diff --git a/src/main/scala/gitbucket/core/util/JGitUtil.scala b/src/main/scala/gitbucket/core/util/JGitUtil.scala index 9413e0608..bef631af6 100644 --- a/src/main/scala/gitbucket/core/util/JGitUtil.scala +++ b/src/main/scala/gitbucket/core/util/JGitUtil.scala @@ -831,15 +831,16 @@ object JGitUtil { .find(_._1 != null) } - def createTag(git: Git, name: String, message: String, commitId: String) = { + def createTag(git: Git, name: String, message: Option[String], commitId: String) = { try { val objectId: ObjectId = git.getRepository.resolve(commitId) - val walk: RevWalk = new RevWalk(git.getRepository) - val tagCommand = git.tag().setName(name).setObjectId(walk.parseCommit(objectId)) - if (!message.isEmpty) { - tagCommand.setMessage(message) + using(new RevWalk(git.getRepository)) { walk => + val tagCommand = git.tag().setName(name).setObjectId(walk.parseCommit(objectId)) + message.foreach { message => + tagCommand.setMessage(message) + } + tagCommand.call() } - tagCommand.call() Right("Tag added.") } catch { case e: GitAPIException => Left("Sorry, some Git operation error occurs.") diff --git a/src/main/twirl/gitbucket/core/repo/commit.scala.html b/src/main/twirl/gitbucket/core/repo/commit.scala.html index e0e7d54ed..b0ebe7651 100644 --- a/src/main/twirl/gitbucket/core/repo/commit.scala.html +++ b/src/main/twirl/gitbucket/core/repo/commit.scala.html @@ -20,21 +20,7 @@
Browse code @if(hasWritePermission) { - - + Add tag }
@helpers.link(commit.summary, repository)
diff --git a/src/main/twirl/gitbucket/core/repo/tag.scala.html b/src/main/twirl/gitbucket/core/repo/tag.scala.html new file mode 100644 index 000000000..6f40e9bd1 --- /dev/null +++ b/src/main/twirl/gitbucket/core/repo/tag.scala.html @@ -0,0 +1,26 @@ +@(commitId: String, + repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) +@import gitbucket.core.view.helpers +

+ Add tag +

+
+
+
+ + + +
+
+
+
+ + + +
+
+
+ + +
+
From 103800f911ad76d26ce31461b4cb979bb8b129d9 Mon Sep 17 00:00:00 2001 From: Uli Heller Date: Mon, 23 Jul 2018 11:13:20 +0200 Subject: [PATCH 13/17] postgresql: 42.1.4 -> 42.2.4 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 5d06b1cff..76fd41ae7 100644 --- a/build.sbt +++ b/build.sbt @@ -48,7 +48,7 @@ libraryDependencies ++= Seq( "com.novell.ldap" % "jldap" % "2009-10-07", "com.h2database" % "h2" % "1.4.196", "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.6", - "org.postgresql" % "postgresql" % "42.1.4", + "org.postgresql" % "postgresql" % "42.2.4", "ch.qos.logback" % "logback-classic" % "1.2.3", "com.zaxxer" % "HikariCP" % "2.7.4", "com.typesafe" % "config" % "1.3.2", From 377376d457608a887796e94412995668dcb58698 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 23 Jul 2018 18:23:03 +0900 Subject: [PATCH 14/17] (Refs #2082)Fix to export orphan tables as well --- src/main/scala/gitbucket/core/util/JDBCUtil.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/gitbucket/core/util/JDBCUtil.scala b/src/main/scala/gitbucket/core/util/JDBCUtil.scala index bb3b16003..2662e6393 100644 --- a/src/main/scala/gitbucket/core/util/JDBCUtil.scala +++ b/src/main/scala/gitbucket/core/util/JDBCUtil.scala @@ -202,8 +202,7 @@ object JDBCUtil { private def allTablesOrderByDependencies(meta: DatabaseMetaData): Seq[String] = { val tables = allTableNames.map { tableName => - val result = TableDependency(tableName, childTables(meta, tableName)) - result + TableDependency(tableName, childTables(meta, tableName)) } val edges = tables.flatMap { table => @@ -212,7 +211,10 @@ object JDBCUtil { } } - tsort(edges).toSeq + val ordered = tsort(edges).toSeq + val orphans = tables.collect { case x if !ordered.contains(x.tableName) => x.tableName } + + ordered ++ orphans } def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = { From ec5d8560d851e43d10904d928697e35276e2cefa Mon Sep 17 00:00:00 2001 From: jyuch Date: Thu, 26 Jul 2018 21:33:30 +0900 Subject: [PATCH 15/17] (refs #2120) Fix database export failure --- src/main/scala/gitbucket/core/util/JDBCUtil.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/gitbucket/core/util/JDBCUtil.scala b/src/main/scala/gitbucket/core/util/JDBCUtil.scala index 2662e6393..9d34c8483 100644 --- a/src/main/scala/gitbucket/core/util/JDBCUtil.scala +++ b/src/main/scala/gitbucket/core/util/JDBCUtil.scala @@ -143,6 +143,7 @@ object JDBCUtil { case Types.BOOLEAN | Types.BIT => rs.getBoolean(columnName) case Types.VARCHAR | Types.CLOB | Types.CHAR | Types.LONGVARCHAR => rs.getString(columnName) case Types.INTEGER => rs.getInt(columnName) + case Types.BIGINT => rs.getLong(columnName) case Types.TIMESTAMP => rs.getTimestamp(columnName) } } From f4865adecf97ac7e4f89bac088d56d9593ff6a77 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sat, 28 Jul 2018 13:51:49 +0900 Subject: [PATCH 16/17] Preparation of GitBucket 4.27.0 release --- CHANGELOG.md | 5 +++++ README.md | 13 +++++-------- build.sbt | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 143e61986..3d8ae9ca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All changes to the project will be documented in this file. +### 4.27.0 - 29 Jul 2018 +- Create new tag on the browser +- EditorConfig support +- Improve issues / pull requests search + ### 4.26.0 - 30 Jun 2018 - Installing plugins from the central registry - Repositories tab in the dashboard diff --git a/README.md b/README.md index 6307665aa..e679bfbeb 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,11 @@ Support - If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue. - The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles. -What's New in 4.26.x +What's New in 4.27.x ------------- -### 4.26.0 - 30 Jun 2018 -- Installing plugins from the central registry -- Repositories tab in the dashboard -- Fork dialog enhancement -- Adjust pull request creation suggestor -- Keep showing incompleted task list -- New notification hooks +### 4.27.0 - 29 Jul 2018 +- Create new tag on the browser +- EditorConfig support +- Improve issues / pull requests search See the [change log](CHANGELOG.md) for all of the updates. diff --git a/build.sbt b/build.sbt index 76fd41ae7..f37c81593 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ import com.typesafe.sbt.pgp.PgpKeys._ val Organization = "io.github.gitbucket" val Name = "gitbucket" -val GitBucketVersion = "4.26.0" +val GitBucketVersion = "4.27.0" val ScalatraVersion = "2.6.1" val JettyVersion = "9.4.7.v20170914" From cb920feb24492bfbe7641f0390a7ed056895c355 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sun, 29 Jul 2018 11:59:22 +0900 Subject: [PATCH 17/17] Update changelog of 4.27.0 --- CHANGELOG.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8ae9ca2..66987e431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All changes to the project will be documented in this file. - Create new tag on the browser - EditorConfig support - Improve issues / pull requests search +- Some improvements and bug fixes for plugin installation via internet and pull request commenting ### 4.26.0 - 30 Jun 2018 - Installing plugins from the central registry diff --git a/README.md b/README.md index e679bfbeb..e46cbb64b 100644 --- a/README.md +++ b/README.md @@ -74,5 +74,6 @@ What's New in 4.27.x - Create new tag on the browser - EditorConfig support - Improve issues / pull requests search +- Some improvements and bug fixes for plugin installation via internet and pull request commenting See the [change log](CHANGELOG.md) for all of the updates.