Page: Compare 2 commits

This commit is contained in:
Unknwon 2014-10-10 21:40:51 -04:00
parent 54930c001d
commit b2632dec09
19 changed files with 379 additions and 145 deletions

View File

@ -32,6 +32,7 @@ The goal of this project is to make the easiest, fastest and most painless way t
- Activity timeline - Activity timeline
- SSH/HTTP(S) protocol support - SSH/HTTP(S) protocol support
- SMTP/LDAP/reverse proxy authentication support - SMTP/LDAP/reverse proxy authentication support
- Reverse proxy suburl support
- Register/delete/rename account - Register/delete/rename account
- Create/manage/delete organization with team management - Create/manage/delete organization with team management
- Create/migrate/mirror/delete/watch/rename/transfer public/private repository - Create/migrate/mirror/delete/watch/rename/transfer public/private repository

View File

@ -23,6 +23,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
- 活动时间线 - 活动时间线
- 支持 SSH/HTTP(S) 协议 - 支持 SSH/HTTP(S) 协议
- 支持 SMTP/LDAP/反向代理 用户认证 - 支持 SMTP/LDAP/反向代理 用户认证
- 支持反向代理子路径
- 注册/删除/重命名 用户 - 注册/删除/重命名 用户
- 创建/管理/删除 组织以及团队管理功能 - 创建/管理/删除 组织以及团队管理功能
- 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库 - 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库

View File

@ -60,6 +60,7 @@ func runDump(ctx *cli.Context) {
z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql")) z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql"))
z.AddFile("custom/conf/app.ini", path.Join(workDir, "custom/conf/app.ini")) z.AddFile("custom/conf/app.ini", path.Join(workDir, "custom/conf/app.ini"))
z.AddDir("log", path.Join(workDir, "log")) z.AddDir("log", path.Join(workDir, "log"))
// FIXME: SSH key file.
if err = z.Close(); err != nil { if err = z.Close(); err != nil {
os.Remove(fileName) os.Remove(fileName)
log.Fatalf("Fail to save %s: %v", fileName, err) log.Fatalf("Fail to save %s: %v", fileName, err)

View File

@ -337,6 +337,15 @@ settings.slack_token = Token
settings.slack_domain = Domain settings.slack_domain = Domain
settings.slack_channel = Channel settings.slack_channel = Channel
diff.browse_source = Browse Source
diff.parent = parent
diff.commit = commit
diff.data_not_available = Diff Data Not Available.
diff.show_diff_stats = Show Diff Stats
diff.stats_desc = <strong> %d changed files</strong> with <strong>%d additions</strong> and <strong>%d deletions</strong>
diff.bin = BIN
diff.view_file = View File
[org] [org]
org_name_holder = Organization Name org_name_holder = Organization Name
org_name_helper = Great organization names are short and memorable. org_name_helper = Great organization names are short and memorable.
@ -609,6 +618,7 @@ commit_repo = pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a>
create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a> create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a>
comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a> comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a>
transfer_repo = transfered repository <code>%s</code> to <a href="/%s%s">%s</a> transfer_repo = transfered repository <code>%s</code> to <a href="/%s%s">%s</a>
compare_2_commits = View comparison for these 2 commits
[tool] [tool]
ago = ago ago = ago

View File

@ -337,6 +337,15 @@ settings.slack_token = 令牌
settings.slack_domain = 域名 settings.slack_domain = 域名
settings.slack_channel = 频道 settings.slack_channel = 频道
diff.browse_source = 浏览代码
diff.parent = 父节点
diff.commit = 当前提交
diff.data_not_available = 暂无可用数据
diff.show_diff_stats = 显示文件统计
diff.stats_desc = 共有 <strong> %d 个文件被更改</strong>,包括 <strong>%d 次插入</strong> 和 <strong>%d 次删除</strong>
diff.bin = 二进制
diff.view_file = 查看文件
[org] [org]
org_name_holder = 组织名称 org_name_holder = 组织名称
org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。 org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。
@ -609,6 +618,7 @@ commit_repo = 推送了 <a href="%s/%s/src/%s">%s</a> 分支的代码到 <a href
create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a> create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a>
comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a> comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a>
transfer_repo = 将仓库 <code>%s</code> 转移至 <a href="/%s%s">%s</a> transfer_repo = 将仓库 <code>%s</code> 转移至 <a href="/%s%s">%s</a>
compare_2_commits = 查看 2 次提交的内容对比
[tool] [tool]
ago = 之前 ago = 之前

View File

@ -181,13 +181,19 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
commit = &base.PushCommits{} commit = &base.PushCommits{}
} }
refName := git.RefEndName(refFullName) repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
// if not the first commit, set the compareUrl
if !strings.HasPrefix(oldCommitId, "0000000") {
commit.CompareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
}
bs, err := json.Marshal(commit) bs, err := json.Marshal(commit)
if err != nil { if err != nil {
return errors.New("action.CommitRepoAction(json): " + err.Error()) return errors.New("action.CommitRepoAction(json): " + err.Error())
} }
refName := git.RefEndName(refFullName)
// Change repository bare status and update last updated time. // Change repository bare status and update last updated time.
repo, err := GetRepositoryByName(repoUserId, repoName) repo, err := GetRepositoryByName(repoUserId, repoName)
if err != nil { if err != nil {
@ -211,7 +217,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error()) return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error())
} }
//qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName)
// New push event hook. // New push event hook.
if err := repo.GetOwner(); err != nil { if err := repo.GetOwner(); err != nil {
@ -237,13 +242,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
return nil return nil
} }
repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
compareUrl := ""
// if not the first commit, set the compareUrl
if !strings.HasPrefix(oldCommitId, "0000000") {
compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
}
pusher_email, pusher_name := "", "" pusher_email, pusher_name := "", ""
pusher, err := GetUserByName(userName) pusher, err := GetUserByName(userName)
if err == nil { if err == nil {
@ -293,7 +291,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
}, },
Before: oldCommitId, Before: oldCommitId,
After: newCommitId, After: newCommitId,
CompareUrl: compareUrl, CompareUrl: commit.CompareUrl,
} }
for _, w := range ws { for _, w := range ws {

View File

@ -106,7 +106,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
if err = CommitRepoAction(userId, ru.Id, userName, actEmail, if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil { repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil {
log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) log.GitLogger.Fatal(4, "CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
} }
return err return err
} }
@ -116,8 +116,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err) return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err)
} }
// Push new branch.
var l *list.List var l *list.List
// if a new branch
if isNew { if isNew {
l, err = newCommit.CommitsBefore() l, err = newCommit.CommitsBefore()
if err != nil { if err != nil {
@ -134,7 +134,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
return fmt.Errorf("runUpdate.Commit repoId: %v", err) return fmt.Errorf("runUpdate.Commit repoId: %v", err)
} }
// if commits push // Push commits.
commits := make([]*base.PushCommit, 0) commits := make([]*base.PushCommit, 0)
var actEmail string var actEmail string
for e := l.Front(); e != nil; e = e.Next() { for e := l.Front(); e != nil; e = e.Next() {
@ -153,9 +153,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
} }
} }
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
if err = CommitRepoAction(userId, ru.Id, userName, actEmail, if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}, oldCommitId, newCommitId); err != nil { repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil {
return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
} }
return nil return nil

View File

@ -5,7 +5,6 @@
package base package base
import ( import (
"bytes"
"container/list" "container/list"
"encoding/json" "encoding/json"
"errors" "errors"
@ -107,7 +106,6 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
return a + b return a + b
}, },
"ActionIcon": ActionIcon, "ActionIcon": ActionIcon,
"ActionDesc": ActionDesc,
"DateFormat": DateFormat, "DateFormat": DateFormat,
"List": List, "List": List,
"Mail2Domain": func(mail string) string { "Mail2Domain": func(mail string) string {
@ -162,19 +160,6 @@ func ActionIcon(opType int) string {
} }
} }
// FIXME: Legacy
const (
TPL_CREATE_REPO = `<a href="%s/user/%s">%s</a> created repository <a href="%s">%s</a>`
TPL_COMMIT_REPO = `<a href="%s/user/%s">%s</a> pushed to <a href="%s/src/%s">%s</a> at <a href="%s">%s</a>%s`
TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="%s/commit/%s" rel="nofollow">%s</a> %s</div>`
TPL_CREATE_ISSUE = `<a href="%s/user/%s">%s</a> opened issue <a href="%s/issues/%s">%s#%s</a>
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
TPL_TRANSFER_REPO = `<a href="%s/user/%s">%s</a> transfered repository <code>%s</code> to <a href="%s">%s</a>`
TPL_PUSH_TAG = `<a href="%s/user/%s">%s</a> pushed tag <a href="%s/src/%s" rel="nofollow">%s</a> at <a href="%s">%s</a>`
TPL_COMMENT_ISSUE = `<a href="%s/user/%s">%s</a> commented on issue <a href="%s/issues/%s">%s#%s</a>
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
)
type PushCommit struct { type PushCommit struct {
Sha1 string Sha1 string
Message string Message string
@ -183,8 +168,9 @@ type PushCommit struct {
} }
type PushCommits struct { type PushCommits struct {
Len int Len int
Commits []*PushCommit Commits []*PushCommit
CompareUrl string
} }
func ActionContent2Commits(act Actioner) *PushCommits { func ActionContent2Commits(act Actioner) *PushCommits {
@ -195,52 +181,6 @@ func ActionContent2Commits(act Actioner) *PushCommits {
return push return push
} }
// FIXME: Legacy
// ActionDesc accepts int that represents action operation type
// and returns the description.
func ActionDesc(act Actioner) string {
actUserName := act.GetActUserName()
email := act.GetActEmail()
repoUserName := act.GetRepoUserName()
repoName := act.GetRepoName()
repoLink := repoUserName + "/" + repoName
branch := act.GetBranch()
content := act.GetContent()
switch act.GetOpType() {
case 1: // Create repository.
return fmt.Sprintf(TPL_CREATE_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, repoName)
case 5: // Commit repository.
var push *PushCommits
if err := json.Unmarshal([]byte(content), &push); err != nil {
return err.Error()
}
buf := bytes.NewBuffer([]byte("\n"))
for _, commit := range push.Commits {
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
}
if push.Len > 3 {
buf.WriteString(fmt.Sprintf(`<div><a href="{{AppRootSubUrl}}/%s/%s/commits/%s" rel="nofollow">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
}
return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink,
buf.String())
case 6: // Create issue.
infos := strings.SplitN(content, "|", 2)
return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
AvatarLink(email), infos[1])
case 8: // Transfer repository.
newRepoLink := content + "/" + repoName
return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink)
case 9: // Push tag.
return fmt.Sprintf(TPL_PUSH_TAG, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink)
case 10: // Comment issue.
infos := strings.SplitN(content, "|", 2)
return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
AvatarLink(email), infos[1])
default:
return "invalid type"
}
}
func DiffTypeToStr(diffType int) string { func DiffTypeToStr(diffType int) string {
diffTypes := map[int]string{ diffTypes := map[int]string{
1: "add", 2: "modify", 3: "del", 1: "add", 2: "modify", 3: "del",

View File

@ -271,6 +271,10 @@ img.avatar-100 {
.pagination li { .pagination li {
display: inline; display: inline;
} }
.list-unstyled {
padding-left: 0;
list-style: none;
}
.markdown { .markdown {
background-color: white; background-color: white;
font-size: 16px; font-size: 16px;
@ -1487,6 +1491,106 @@ The register and sign-in page style
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace; font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
font-size: 14px; font-size: 14px;
} }
.diff-head-box {
margin-top: 10px;
}
.diff-head-box .panel-body {
padding: 10px 15px 5px 10px;
}
.diff-head-box .author img {
margin-top: -7px;
}
.diff-detail-box {
margin: 15px 0;
line-height: 30px;
}
.diff-detail-box ol {
clear: both;
padding-left: 0;
margin-bottom: 28px;
}
.diff-detail-box ol li {
list-style: none;
padding-bottom: 4px;
margin-bottom: 4px;
border-bottom: 1px dashed #DDD;
padding-left: 6px;
}
.diff-detail-box span.status {
display: inline-block;
width: 12px;
height: 12px;
margin-right: 8px;
vertical-align: middle;
}
.diff-detail-box span.status.modify {
background-color: #f0db88;
}
.diff-detail-box span.status.add {
background-color: #b4e2b4;
}
.diff-detail-box span.status.del {
background-color: #e9aeae;
}
.diff-detail-box span.status.rename {
background-color: #dad8ff;
}
.diff-box .count {
margin-right: 12px;
}
.diff-box .count .bar {
background-color: #e75316;
height: 12px;
width: 40px;
display: inline-block;
margin: 2px 4px 0 4px;
vertical-align: text-top;
}
.diff-box .count .bar .add {
background-color: #77c64a;
height: 12px;
}
.diff-box .file {
color: #888;
}
.diff-box .panel-header {
font-size: 14px;
}
.diff-file-box .code-diff tbody tr:hover td,
.diff-file-box .code-diff tbody tr:hover pre {
background-color: #FFF8D2 !important;
border-color: #F0DB88 !important;
}
.diff-file-box .file-body.file-code .lines-num-old {
border-right: 1px solid #DDD;
}
.file-content .file-body.file-code .lines-num {
text-align: right;
color: #999;
background: #fafafa;
width: 1%;
}
.diff-file-box .code-diff tbody tr.tag-code td,
.diff-file-box .code-diff tbody tr.tag-code pre {
background-color: #E0E0E0 !important;
border-color: #ADADAD !important;
}
.diff-file-box .code-diff tbody tr.del-code td,
.diff-file-box .code-diff tbody tr.del-code pre {
background-color: #ffe2dd !important;
border-color: #e9aeae !important;
}
.diff-file-box .code-diff tbody tr.add-code td,
.diff-file-box .code-diff tbody tr.add-code pre {
background-color: #d1ffd6 !important;
border-color: #b4e2b4 !important;
}
.compare-head-box {
margin-top: 10px;
}
.compare-head-box .compare {
padding: 0 15px 15px 15px;
}
#admin-wrapper, #admin-wrapper,
#setting-wrapper { #setting-wrapper {
padding-bottom: 100px; padding-bottom: 100px;

View File

@ -713,6 +713,14 @@ ul.menu-radius > li:last-child > a {
border-bottom-left-radius: .3em; border-bottom-left-radius: .3em;
border-bottom-right-radius: .3em; border-bottom-right-radius: .3em;
} }
.panel.panel-info {
border-color: #85c5e5;
}
.panel.panel-info > .panel-header {
color: #31708f;
background-color: #d9edf7;
border-color: #85c5e5;
}
.panel.panel-warning { .panel.panel-warning {
border-color: #F0C36D; border-color: #F0C36D;
} }

View File

@ -299,6 +299,9 @@ function initCore() {
e.preventDefault(); e.preventDefault();
$.magnificPopup.close(); $.magnificPopup.close();
}); });
// Collapse.
$('.collapse').hide();
} }
function initUserSetting() { function initUserSetting() {
@ -698,6 +701,37 @@ function initProfile() {
}); });
} }
function initTimeSwitch() {
// Time switch.
$(".time-since[title]").on("click", function () {
var $this = $(this);
var title = $this.attr("title");
var text = $this.text();
$this.text(title);
$this.attr("title", text);
});
}
function initDiff() {
$('.diff-detail-box>a').click(function () {
$($(this).data('target')).slideToggle(100);
})
var $counter = $('.diff-counter');
if ($counter.length < 1) {
return;
}
$counter.each(function (i, item) {
var $item = $(item);
var addLine = $item.find('span[data-line].add').data("line");
var delLine = $item.find('span[data-line].del').data("line");
var addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100;
$item.find(".bar .add").css("width", addPercent + "%");
});
}
$(document).ready(function () { $(document).ready(function () {
Gogs.AppSubUrl = $('head').data('suburl') || ''; Gogs.AppSubUrl = $('head').data('suburl') || '';
initCore(); initCore();
@ -737,6 +771,10 @@ $(document).ready(function () {
if ($('#user-profile-page').length) { if ($('#user-profile-page').length) {
initProfile(); initProfile();
} }
if ($('#diff-page').length) {
initTimeSwitch();
initDiff();
}
$('#dashboard-sidebar-menu').tabs(); $('#dashboard-sidebar-menu').tabs();
$('#pull-issue-preview').markdown_preview(".issue-add-comment"); $('#pull-issue-preview').markdown_preview(".issue-add-comment");

File diff suppressed because one or more lines are too long

View File

@ -292,3 +292,7 @@ clear: both;
display: inline; display: inline;
} }
} }
.list-unstyled {
padding-left: 0;
list-style: none;
}

View File

@ -494,37 +494,138 @@
} }
} }
.repo-user-list-block { .repo-user-list-block {
position: relative; position: relative;
top: 5px; top: 5px;
} }
.setting-list { .setting-list {
width: 100%; width: 100%;
list-style: none; list-style: none;
} }
#commits-list { #commits-list {
padding-top: 20px; padding-top: 20px;
h4{ h4{
line-height: 30px; line-height: 30px;
margin-bottom: 0; margin-bottom: 0;
} }
} }
.commit-list { .commit-list {
th { th {
background-color: #FFF; background-color: #FFF;
line-height: 28px !important; line-height: 28px !important;
} }
.date { .date {
width: 120px; width: 120px;
} }
.author { .author {
padding-left: 20px; padding-left: 20px;
min-width: 180px; min-width: 180px;
img { img {
margin-top: -4px; margin-top: -4px;
}
}
.sha a {
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
font-size: 14px;
}
}
.diff-head-box {
margin-top: 10px;
.panel-body {
padding: 10px 15px 5px 10px;
}
.author {
img {
margin-top: -7px;
}
}
}
.diff-detail-box {
margin: 15px 0;
line-height: 30px;
ol {
clear: both;
padding-left: 0;
margin-bottom: 28px;
li {
list-style: none;
padding-bottom: 4px;
margin-bottom: 4px;
border-bottom: 1px dashed #DDD;
padding-left: 6px;
}
}
span.status{
display: inline-block;
width: 12px;
height: 12px;
margin-right: 8px;
vertical-align: middle;
&.modify {
background-color: #f0db88;
}
&.add {
background-color: #b4e2b4;
}
&.del {
background-color: #e9aeae;
}
&.rename {
background-color: #dad8ff;
}
}
}
.diff-box {
.count {
margin-right: 12px;
.bar {
background-color: #e75316;
height: 12px;
width: 40px;
display: inline-block;
margin: 2px 4px 0 4px;
vertical-align: text-top;
.add {
background-color: #77c64a;
height: 12px;
}
}
}
.file {
color: #888;
}
.panel-header {
font-size: 14px;
}
}
.diff-file-box .code-diff tbody tr:hover td, .diff-file-box .code-diff tbody tr:hover pre {
background-color: #FFF8D2 !important;
border-color: #F0DB88 !important;
}
.diff-file-box .file-body.file-code .lines-num-old {
border-right: 1px solid #DDD;
}
.file-content .file-body.file-code .lines-num {
text-align: right;
color: #999;
background: #fafafa;
width: 1%;
}
.diff-file-box .code-diff tbody tr.tag-code td, .diff-file-box .code-diff tbody tr.tag-code pre {
background-color: #E0E0E0 !important;
border-color: #ADADAD !important;
}
.diff-file-box .code-diff tbody tr.del-code td, .diff-file-box .code-diff tbody tr.del-code pre {
background-color: #ffe2dd !important;
border-color: #e9aeae !important;
}
.diff-file-box .code-diff tbody tr.add-code td, .diff-file-box .code-diff tbody tr.add-code pre {
background-color: #d1ffd6 !important;
border-color: #b4e2b4 !important;
}
.compare-head-box {
margin-top: 10px;
.compare {
padding: 0 15px 15px 15px;
} }
}
.sha a {
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
font-size: 14px;
}
} }

View File

@ -36,6 +36,14 @@
border-bottom-right-radius: .3em; border-bottom-right-radius: .3em;
} }
} }
&.panel-info {
border-color: #85c5e5;
> .panel-header {
color: #31708f;
background-color: #d9edf7;
border-color: #85c5e5;
}
}
&.panel-warning { &.panel-warning {
border-color: #F0C36D; border-color: #F0C36D;
> .panel-header { > .panel-header {

View File

@ -159,6 +159,7 @@ func Diff(ctx *middleware.Context) {
ctx.Data["IsImageFile"] = isImageFile ctx.Data["IsImageFile"] = isImageFile
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId) ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId)
ctx.Data["Commit"] = commit ctx.Data["Commit"] = commit
ctx.Data["Author"] = models.ValidateCommitWithEmail(commit)
ctx.Data["Diff"] = diff ctx.Data["Diff"] = diff
ctx.Data["Parents"] = parents ctx.Data["Parents"] = parents
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
@ -212,6 +213,7 @@ func CompareDiff(ctx *middleware.Context) {
ctx.Handle(500, "CommitsBeforeUntil", err) ctx.Handle(500, "CommitsBeforeUntil", err)
return return
} }
commits = models.ValidateCommitsWithEmails(commits)
ctx.Data["Commits"] = commits ctx.Data["Commits"] = commits
ctx.Data["CommitCount"] = commits.Len() ctx.Data["CommitCount"] = commits.Len()

View File

@ -1,10 +1,12 @@
<div id="commits-list"> <div id="commits-list">
<div class="panel panel-radius"> <div class="panel panel-radius">
<div class="panel-header"> <div class="panel-header">
{{if not .IsDiffCompare}}
<form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form"> <form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
<input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" /> <input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" />
<button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button> <button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button>
</form> </form>
{{end}}
<h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4> <h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4>
</div> </div>
<table class="panel-body table commit-list table-striped"> <table class="panel-body table commit-list table-striped">
@ -31,7 +33,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{{if not .IsSearchPage}} {{if and (not .IsSearchPage) (not .IsDiffCompare)}}
<ul class="pagination"> <ul class="pagination">
{{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.LastPageNum}}" rel="nofollow">&laquo; {{.i18n.Tr "repo.commits.newer"}}</a></li>{{end}} {{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.LastPageNum}}" rel="nofollow">&laquo; {{.i18n.Tr "repo.commits.newer"}}</a></li>{{end}}
{{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.NextPageNum}}" rel="nofollow">&raquo; {{.i18n.Tr "repo.commits.older"}}</a></li>{{end}} {{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.NextPageNum}}" rel="nofollow">&raquo; {{.i18n.Tr "repo.commits.older"}}</a></li>{{end}}

View File

@ -1,49 +1,54 @@
{{template "base/head" .}} {{template "ng/base/head" .}}
{{template "base/navbar" .}} {{template "ng/base/header" .}}
{{template "repo/nav" .}} <div id="repo-wrapper">
<div id="body" class="container" data-page="repo"> {{template "repo/header" .}}
<div id="source"> <div class="container clear" id="diff-page">
{{if .IsDiffCompare }} {{if .IsDiffCompare }}
<div class="panel panel-info diff-box diff-head-box"> <div class="panel panel-info panel-radius compare-head-box">
<div class="panel-heading"> <div class="panel-header">
<a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a> <a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
<h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-success">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-success">{{ShortSha .AfterCommitId}}</a></h4> <h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-green">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-green">{{ShortSha .AfterCommitId}}</a></h4>
</div> </div>
<div class="panel-body compare"> <div class="panel-body compare">
{{template "repo/commits_table" .}} {{template "repo/commits_table" .}}
</div> </div>
</div> </div>
{{else}} {{else}}
<div class="panel panel-info diff-box diff-head-box"> <div class="panel panel-info panel-radius diff-head-box">
<div class="panel-heading"> <div class="panel-header">
<a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a> <a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
<h4>{{.Commit.Message}}</h4> <h4>{{.Commit.Message}}</h4>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<span class="pull-right"> <span class="pull-right">
<ul class="list-unstyled"> <ul class="list-unstyled">
{{range .Parents}} <li class="inline">{{.i18n.Tr "repo.diff.parent"}}</li>
<li>parent <a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-default sha">{{ShortSha .}}</span></a></li> {{range .Parents}}
{{end}} <li class="inline"><a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-blue">{{ShortSha .}}</span></a></li>
<li>commit <span class="label label-default sha">{{ShortSha .CommitId}}</span></li> {{end}}
</ul> <li class="inline">{{.i18n.Tr "repo.diff.commit"}} <span class="label label-blue">{{ShortSha .CommitId}}</span></li>
</ul>
</span> </span>
<p class="author"> <p class="author">
<img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/> <img class="avatar-30" src="{{AvatarLink .Commit.Author.Email}}" />
<a class="name" href="{{AppSubUrl}}/user/email2user?email={{.Commit.Author.Email}}"><strong>{{.Commit.Author.Name}}</strong></a> {{if .Author}}
<span class="time">{{TimeSince .Commit.Author.When $.Lang}}</span> <a href="{{AppSubUrl}}/{{.Author}}"><strong>{{.Commit.Author.Name}}</strong></a>
{{else}}
<strong>{{.Commit.Author.Name}}</strong>
{{end}}
<span class="text-grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span>
</p> </p>
</div> </div>
</div> </div>
{{end}} {{end}}
{{if .DiffNotAvailable}} {{if .DiffNotAvailable}}
<h4>Diff Data Not Available.</h4> <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
{{else}} {{else}}
<div class="diff-detail-box diff-box"> <div class="diff-detail-box diff-box">
<a class="pull-right btn btn-default" data-toggle="collapse" data-target="#diff-files">Show Diff Stats</a> <a class="pull-right btn btn-gray btn-header btn-radius text-black" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
<p class="showing"> <p class="showing">
<i class="fa fa-retweet"></i> <i class="fa fa-retweet"></i>
<strong> {{.Diff.NumFiles}} changed files</strong> with <strong>{{.Diff.TotalAddition}} additions</strong> and <strong>{{.Diff.TotalDeletion}} deletions</strong>. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
</p> </p>
<ol class="detail-files collapse" id="diff-files"> <ol class="detail-files collapse" id="diff-files">
{{range .Diff.Files}} {{range .Diff.Files}}
@ -57,7 +62,7 @@
</span> </span>
<span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span> <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
{{else}} {{else}}
<span>BIN</span> <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
{{end}} {{end}}
</div> </div>
<!-- todo finish all file status, now modify, add, delete and rename --> <!-- todo finish all file status, now modify, add, delete and rename -->
@ -69,8 +74,8 @@
</div> </div>
{{range .Diff.Files}} {{range .Diff.Files}}
<div class="panel panel-default diff-file-box diff-box file-content" id="diff-{{.Index}}"> <div class="panel diff-file-box diff-box file-content" id="diff-{{.Index}}">
<div class="panel-heading"> <div class="panel-header">
<div class="diff-counter count pull-left"> <div class="diff-counter count pull-left">
{{if not .IsBin}} {{if not .IsBin}}
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span> <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
@ -80,10 +85,10 @@
</span> </span>
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span> <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
{{else}} {{else}}
BIN {{$.i18n.Tr "repo.diff.bin"}}
{{end}} {{end}}
</div> </div>
<a class="btn btn-default btn-sm pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">View File</a> <a class="btn btn-gray btn-header btn-radius text-black pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
<span class="file">{{.Name}}</span> <span class="file">{{.Name}}</span>
</div> </div>
{{$isImage := (call $.IsImageFile .Name)}} {{$isImage := (call $.IsImageFile .Name)}}
@ -115,8 +120,9 @@
{{end}} {{end}}
</div> </div>
</div> </div>
<br>
{{end}} {{end}}
{{end}} {{end}}
</div> </div>
</div> </div>
{{template "base/footer" .}} {{template "ng/base/footer" .}}

View File

@ -28,6 +28,7 @@
{{range $push.Commits}} {{range $push.Commits}}
<li><img class="avatar-16" src="{{AvatarLink .AuthorEmail}}?s=16"> <a href="{{AppSubUrl}}/{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text-truncate grid-4-5">{{.Message}}</span></li> <li><img class="avatar-16" src="{{AvatarLink .AuthorEmail}}?s=16"> <a href="{{AppSubUrl}}/{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text-truncate grid-4-5">{{.Message}}</span></li>
{{end}} {{end}}
{{if $push.CompareUrl}}<li><a href="{{$push.CompareUrl}}">{{$.i18n.Tr "action.compare_2_commits"}} »</a></li>{{end}}
</ul> </ul>
</div> </div>
{{else if eq .GetOpType 6}} {{else if eq .GetOpType 6}}