Fix message for empty repository

This commit is contained in:
Naoki Takezoe
2014-04-11 11:57:16 +09:00
parent 2ae7798591
commit 9c4f7cc530
4 changed files with 25 additions and 20 deletions

View File

@@ -264,7 +264,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
*/ */
private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = { private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = {
if(repository.commitCount == 0){ if(repository.commitCount == 0){
repo.html.guide(repository) repo.html.guide(repository, hasWritePermission(repository.owner, repository.name, context.loginAccount))
} else { } else {
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git => using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
//val revisions = Seq(if(revstr.isEmpty) repository.repository.defaultBranch else revstr, repository.branchList.head) //val revisions = Seq(if(revstr.isEmpty) repository.repository.defaultBranch else revstr, repository.branchList.head)

View File

@@ -137,7 +137,7 @@ object JGitUtil {
using(Git.open(getRepositoryDir(owner, repository))){ git => using(Git.open(getRepositoryDir(owner, repository))){ git =>
try { try {
// get commit count // get commit count
val commitCount = git.log.all.call.iterator.asScala.map(_ => 1).take(10000).sum val commitCount = git.log.all.call.iterator.asScala.map(_ => 1).take(10001).sum
RepositoryInfo( RepositoryInfo(
owner, repository, s"${baseUrl}/git/${owner}/${repository}.git", owner, repository, s"${baseUrl}/git/${owner}/${repository}.git",

View File

@@ -12,7 +12,7 @@
<div class="head"> <div class="head">
<div class="pull-right"> <div class="pull-right">
@defining(repository.commitCount){ commitCount => @defining(repository.commitCount){ commitCount =>
<a href="@url(repository)/commits/@encodeRefName(branch)">@if(commitCount > 10000){ @commitCount+ } else { @commitCount } @plural(commitCount, "commit")</a>&nbsp; <a href="@url(repository)/commits/@encodeRefName(branch)">@if(commitCount > 10000){ 10000+ } else { @commitCount } @plural(commitCount, "commit")</a>&nbsp;
} }
</div> </div>
<a href="@url(repository)/tree/@encodeRefName(branch)">@repository.name</a> / <a href="@url(repository)/tree/@encodeRefName(branch)">@repository.name</a> /

View File

@@ -1,21 +1,26 @@
@(repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(repository: service.RepositoryService.RepositoryInfo,
hasWritePermission: Boolean)(implicit context: app.Context)
@import context._ @import context._
@import view.helpers._ @import view.helpers._
@html.main(s"${repository.owner}/${repository.name}", Some(repository)) { @html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
@html.header("code", repository) @html.header("code", repository)
<h3 style="margin-top: 30px;">Create a new repository on the command line</h3> @if(!hasWritePermission){
<pre> <h3>This is an empty repository</h3>
touch README.md } else {
git init <h3 style="margin-top: 30px;">Create a new repository on the command line</h3>
git add README.md <pre>
git commit -m "first commit" touch README.md
git remote add origin @repository.httpUrl git init
git push -u origin master git add README.md
</pre> git commit -m "first commit"
git remote add origin @repository.httpUrl
git push -u origin master
</pre>
<h3 style="margin-top: 30px;">Push an existing repository from the command line</h3> <h3 style="margin-top: 30px;">Push an existing repository from the command line</h3>
<pre> <pre>
git remote add origin @repository.httpUrl git remote add origin @repository.httpUrl
git push -u origin master git push -u origin master
</pre> </pre>
}
} }