From: James Moger Date: Tue, 6 Nov 2012 22:47:52 +0000 (-0500) Subject: Added setting to control length of abbreviated commit hash id X-Git-Tag: v1.2.0~93 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=798581cab5817310a1b9991dac3b10cd7813f86a;p=gitblit.git Added setting to control length of abbreviated commit hash id --- diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index 60b1a897..1a5a61b3 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -469,6 +469,11 @@ web.allowZipDownloads = true # SINCE 0.9.0 web.allowLuceneIndexing = true +# Controls the length of shortened commit hash ids +# +# SINCE 1.2.0 +web.shortCommitIdLength = 8 + # Use Clippy (Flash solution) to provide a copy-to-clipboard button. # If false, a button with a more primitive JavaScript-based prompt box will # offer a 3-step (click, ctrl+c, enter) copy-to-clipboard alternative. diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index f0470e5c..a8813c50 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -46,6 +46,8 @@ In order to fork a repository, the user account must have the *fork* permission **New:** *git.garbageCollectionHour = 0* **New:** *git.defaultGarbageCollectionThreshold = 500k* **New:** *git.defaultGarbageCollectionPeriod = 7 days* +- Added setting to control length of shortened commit ids + **New:** *web.shortCommitIdLength=8* - Added simple project pages. A project is a subfolder off the *git.repositoriesFolder*. - Added support for X-Forwarded-Context for Apache subdomain proxy configurations (issue 135) - Delete branch feature (issue 121, Github/ajermakovics) diff --git a/groovy/sendmail-html.groovy b/groovy/sendmail-html.groovy index 72de106e..c3b551d5 100644 --- a/groovy/sendmail-html.groovy +++ b/groovy/sendmail-html.groovy @@ -154,6 +154,7 @@ class HtmlMailWriter { def mountParameters def forwardSlashChar def includeGravatar + def shortCommitIdLength def commitCount = 0 def commands def writer = new StringWriter(); @@ -256,7 +257,7 @@ class HtmlMailWriter { } def writeCommit(commit) { - def abbreviated = repository.newObjectReader().abbreviate(commit.id, 8).name() + def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name() def author = commit.authorIdent.name def email = commit.authorIdent.emailAddress def message = commit.shortMessage @@ -482,6 +483,7 @@ mailWriter.commands = commands mailWriter.url = url mailWriter.mountParameters = gitblit.getBoolean(Keys.web.mountParameters, true) mailWriter.includeGravatar = gitblit.getBoolean(Keys.web.allowGravatar, true) +mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8) def content = mailWriter.write() diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 2bd1ec26..0a399850 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -425,7 +425,7 @@ public abstract class RepositoryPage extends BasePage { } protected String getShortObjectId(String objectId) { - return objectId.substring(0, 8); + return objectId.substring(0, GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)); } protected void addRefs(Repository r, RevCommit c) {