Browse Source

rename fields

tags/v1.21.12.1
Unknwon 10 years ago
parent
commit
1ca257ad9f
11 changed files with 93 additions and 81 deletions
  1. +1
    -0
      conf/locale/locale_en-US.ini
  2. +2
    -2
      modules/bindata/bindata.go
  3. +1
    -1
      modules/middleware/context.go
  4. +6
    -6
      modules/middleware/repo.go
  5. +17
    -17
      routers/repo/commit.go
  6. +41
    -47
      routers/repo/issue.go
  7. +16
    -5
      routers/repo/pull.go
  8. +1
    -1
      templates/repo/commits_table.tmpl
  9. +3
    -1
      templates/repo/diff.tmpl
  10. +4
    -0
      templates/repo/issue/new_form.tmpl
  11. +1
    -1
      templates/repo/view_file.tmpl

+ 1
- 0
conf/locale/locale_en-US.ini View File

@@ -462,6 +462,7 @@ issues.label_deletion_success = Label has been deleted successfully!
pulls.compare_changes = Compare Changes pulls.compare_changes = Compare Changes
pulls.compare_changes_desc = Compare two branches and make a pull request for changes. pulls.compare_changes_desc = Compare two branches and make a pull request for changes.
pulls.no_results = No results found. pulls.no_results = No results found.
pulls.create = Create Pull Request


milestones.new = New Milestone milestones.new = New Milestone
milestones.open_tab = %d Open milestones.open_tab = %d Open


+ 2
- 2
modules/bindata/bindata.go
File diff suppressed because it is too large
View File


+ 1
- 1
modules/middleware/context.go View File

@@ -40,7 +40,7 @@ type RepoContext struct {
BranchName string BranchName string
TagName string TagName string
TreeName string TreeName string
CommitId string
CommitID string
RepoLink string RepoLink string
CloneLink models.CloneLink CloneLink models.CloneLink
CommitsCount int CommitsCount int


+ 6
- 6
modules/middleware/repo.go View File

@@ -118,7 +118,7 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfBranch", err) ctx.Handle(500, "GetCommitOfBranch", err)
return return
} }
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
ctx.Repo.IsBranch = true ctx.Repo.IsBranch = true


} else { } else {
@@ -149,7 +149,7 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfBranch", err) ctx.Handle(500, "GetCommitOfBranch", err)
return return
} }
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()


} else if ctx.Repo.GitRepo.IsTagExist(refName) { } else if ctx.Repo.GitRepo.IsTagExist(refName) {
ctx.Repo.IsTag = true ctx.Repo.IsTag = true
@@ -158,10 +158,10 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfTag", err) ctx.Handle(500, "GetCommitOfTag", err)
return return
} }
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
} else if len(refName) == 40 { } else if len(refName) == 40 {
ctx.Repo.IsCommit = true ctx.Repo.IsCommit = true
ctx.Repo.CommitId = refName
ctx.Repo.CommitID = refName


ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommit(refName) ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommit(refName)
if err != nil { if err != nil {
@@ -176,7 +176,7 @@ func RepoRef() macaron.Handler {


ctx.Repo.BranchName = refName ctx.Repo.BranchName = refName
ctx.Data["BranchName"] = ctx.Repo.BranchName ctx.Data["BranchName"] = ctx.Repo.BranchName
ctx.Data["CommitId"] = ctx.Repo.CommitId
ctx.Data["CommitID"] = ctx.Repo.CommitID
ctx.Data["IsBranch"] = ctx.Repo.IsBranch ctx.Data["IsBranch"] = ctx.Repo.IsBranch
ctx.Data["IsTag"] = ctx.Repo.IsTag ctx.Data["IsTag"] = ctx.Repo.IsTag
ctx.Data["IsCommit"] = ctx.Repo.IsCommit ctx.Data["IsCommit"] = ctx.Repo.IsCommit
@@ -375,7 +375,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
} }


ctx.Data["BranchName"] = ctx.Repo.BranchName ctx.Data["BranchName"] = ctx.Repo.BranchName
ctx.Data["CommitId"] = ctx.Repo.CommitId
ctx.Data["CommitID"] = ctx.Repo.CommitID


userAgent := ctx.Req.Header.Get("User-Agent") userAgent := ctx.Req.Header.Get("User-Agent")
ua := user_agent.New(userAgent) ua := user_agent.New(userAgent)


+ 17
- 17
routers/repo/commit.go View File

@@ -193,12 +193,12 @@ func Diff(ctx *middleware.Context) {


userName := ctx.Repo.Owner.Name userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name repoName := ctx.Repo.Repository.Name
commitId := ctx.Repo.CommitId
commitID := ctx.Repo.CommitID


commit := ctx.Repo.Commit commit := ctx.Repo.Commit
commit.CommitMessage = commit.CommitMessage commit.CommitMessage = commit.CommitMessage
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName),
commitId, setting.Git.MaxGitDiffLines)
commitID, setting.Git.MaxGitDiffLines)
if err != nil { if err != nil {
ctx.Handle(404, "GetDiffCommit", err) ctx.Handle(404, "GetDiffCommit", err)
return return
@@ -236,17 +236,17 @@ func Diff(ctx *middleware.Context) {
ctx.Data["Username"] = userName ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName ctx.Data["Reponame"] = repoName
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["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
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId)
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitID)
if commit.ParentCount() > 0 { if commit.ParentCount() > 0 {
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0]) ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
} }
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId)
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitID)
ctx.HTML(200, DIFF) ctx.HTML(200, DIFF)
} }


@@ -255,17 +255,17 @@ func CompareDiff(ctx *middleware.Context) {
ctx.Data["IsDiffCompare"] = true ctx.Data["IsDiffCompare"] = true
userName := ctx.Repo.Owner.Name userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name repoName := ctx.Repo.Repository.Name
beforeCommitId := ctx.Params(":before")
afterCommitId := ctx.Params(":after")
beforeCommitID := ctx.Params(":before")
afterCommitID := ctx.Params(":after")


commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitId)
commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitID)
if err != nil { if err != nil {
ctx.Handle(404, "GetCommit", err) ctx.Handle(404, "GetCommit", err)
return return
} }


diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId,
afterCommitId, setting.Git.MaxGitDiffLines)
diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitID,
afterCommitID, setting.Git.MaxGitDiffLines)
if err != nil { if err != nil {
ctx.Handle(404, "GetDiffRange", err) ctx.Handle(404, "GetDiffRange", err)
return return
@@ -290,7 +290,7 @@ func CompareDiff(ctx *middleware.Context) {
return isImage return isImage
} }


commits, err := commit.CommitsBeforeUntil(beforeCommitId)
commits, err := commit.CommitsBeforeUntil(beforeCommitID)
if err != nil { if err != nil {
ctx.Handle(500, "CommitsBeforeUntil", err) ctx.Handle(500, "CommitsBeforeUntil", err)
return return
@@ -299,17 +299,17 @@ func CompareDiff(ctx *middleware.Context) {


ctx.Data["Commits"] = commits ctx.Data["Commits"] = commits
ctx.Data["CommitCount"] = commits.Len() ctx.Data["CommitCount"] = commits.Len()
ctx.Data["BeforeCommitId"] = beforeCommitId
ctx.Data["AfterCommitId"] = afterCommitId
ctx.Data["BeforeCommitID"] = beforeCommitID
ctx.Data["AfterCommitID"] = afterCommitID
ctx.Data["Username"] = userName ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName ctx.Data["Reponame"] = repoName
ctx.Data["IsImageFile"] = isImageFile ctx.Data["IsImageFile"] = isImageFile
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitId) + "..." + base.ShortSha(afterCommitId) + " · " + userName + "/" + repoName
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + "..." + base.ShortSha(afterCommitID) + " · " + userName + "/" + repoName
ctx.Data["Commit"] = commit ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff ctx.Data["Diff"] = diff
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", afterCommitId)
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", beforeCommitId)
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", afterCommitId)
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", afterCommitID)
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", beforeCommitID)
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", afterCommitID)
ctx.HTML(200, DIFF) ctx.HTML(200, DIFF)
} }

+ 41
- 47
routers/repo/issue.go View File

@@ -190,39 +190,46 @@ func renderAttachmentSettings(ctx *middleware.Context) {
ctx.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles ctx.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
} }


func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*models.Label {
if !ctx.Repo.IsAdmin() {
return nil
}

labels, err := models.GetLabelsByRepoID(repo.ID)
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID: %v", err)
return nil
}
ctx.Data["Labels"] = labels

ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return nil
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return nil
}

ctx.Data["Assignees"], err = repo.GetAssignees()
if err != nil {
ctx.Handle(500, "GetAssignees: %v", err)
return nil
}
return labels
}

func NewIssue(ctx *middleware.Context) { func NewIssue(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new") ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true ctx.Data["PageIsIssueList"] = true
ctx.Data["RequireDropzone"] = true ctx.Data["RequireDropzone"] = true
renderAttachmentSettings(ctx) renderAttachmentSettings(ctx)


if ctx.Repo.IsAdmin() {
var (
repo = ctx.Repo.Repository
err error
)
ctx.Data["Labels"], err = models.GetLabelsByRepoID(repo.ID)
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID: %v", err)
return
}

ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return
}

ctx.Data["Assignees"], err = repo.GetAssignees()
if err != nil {
ctx.Handle(500, "GetAssignees: %v", err)
return
}
RetrieveRepoMetas(ctx, ctx.Repo.Repository)
if ctx.Written() {
return
} }


ctx.HTML(200, ISSUE_NEW) ctx.HTML(200, ISSUE_NEW)
@@ -240,16 +247,18 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
milestoneID int64 milestoneID int64
assigneeID int64 assigneeID int64
attachments []string attachments []string
err error
) )

if ctx.Repo.IsAdmin() { if ctx.Repo.IsAdmin() {
labels := RetrieveRepoMetas(ctx, repo)
if ctx.Written() {
return
}

// Check labels. // Check labels.
labelIDs = base.StringsToInt64s(strings.Split(form.LabelIDs, ",")) labelIDs = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
labelIDMark := base.Int64sToMap(labelIDs) labelIDMark := base.Int64sToMap(labelIDs)
labels, err := models.GetLabelsByRepoID(repo.ID)
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID: %v", err)
return
}
hasSelected := false hasSelected := false
for i := range labels { for i := range labels {
if labelIDMark[labels[i].ID] { if labelIDMark[labels[i].ID] {
@@ -264,16 +273,6 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
// Check milestone. // Check milestone.
milestoneID = form.MilestoneID milestoneID = form.MilestoneID
if milestoneID > 0 { if milestoneID > 0 {
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones: %v", err)
return
}
ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID) ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
if err != nil { if err != nil {
ctx.Handle(500, "GetMilestoneByID: %v", err) ctx.Handle(500, "GetMilestoneByID: %v", err)
@@ -285,11 +284,6 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
// Check assignee. // Check assignee.
assigneeID = form.AssigneeID assigneeID = form.AssigneeID
if assigneeID > 0 { if assigneeID > 0 {
ctx.Data["Assignees"], err = repo.GetAssignees()
if err != nil {
ctx.Handle(500, "GetAssignees: %v", err)
return
}
ctx.Data["Assignee"], err = repo.GetAssigneeByID(assigneeID) ctx.Data["Assignee"], err = repo.GetAssigneeByID(assigneeID)
if err != nil { if err != nil {
ctx.Handle(500, "GetAssigneeByID: %v", err) ctx.Handle(500, "GetAssigneeByID: %v", err)


+ 16
- 5
routers/repo/pull.go View File

@@ -99,15 +99,13 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {


repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description) repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description)
if err != nil { if err != nil {
ctx.Data["Err_RepoName"] = true
switch { switch {
case models.IsErrRepoAlreadyExist(err): case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), FORK, &form) ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), FORK, &form)
case models.IsErrNameReserved(err): case models.IsErrNameReserved(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(models.ErrNameReserved).Name), FORK, &form) ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(models.ErrNameReserved).Name), FORK, &form)
case models.IsErrNamePatternNotAllowed(err): case models.IsErrNamePatternNotAllowed(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), FORK, &form) ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), FORK, &form)
default: default:
ctx.Handle(500, "ForkPost", err) ctx.Handle(500, "ForkPost", err)
@@ -120,7 +118,12 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
} }


func CompareAndPullRequest(ctx *middleware.Context) { func CompareAndPullRequest(ctx *middleware.Context) {
// Get compare information.
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
ctx.Data["PageIsComparePull"] = true

repo := ctx.Repo.Repository

// Get compare branch information.
infos := strings.Split(ctx.Params("*"), "...") infos := strings.Split(ctx.Params("*"), "...")
if len(infos) != 2 { if len(infos) != 2 {
ctx.Handle(404, "CompareAndPullRequest", nil) ctx.Handle(404, "CompareAndPullRequest", nil)
@@ -144,7 +147,7 @@ func CompareAndPullRequest(ctx *middleware.Context) {


// TODO: add organization support // TODO: add organization support
// Check if current user has fork of repository. // Check if current user has fork of repository.
headRepo, has := models.HasForkedRepo(ctx.User.Id, ctx.Repo.Repository.ID)
headRepo, has := models.HasForkedRepo(ctx.User.Id, repo.ID)
if !has { if !has {
ctx.Handle(404, "HasForkedRepo", nil) ctx.Handle(404, "HasForkedRepo", nil)
return return
@@ -162,6 +165,14 @@ func CompareAndPullRequest(ctx *middleware.Context) {
} }
ctx.Data["HeadBranches"] = headBranches ctx.Data["HeadBranches"] = headBranches


// Setup information for new form.
RetrieveRepoMetas(ctx, ctx.Repo.Repository)
if ctx.Written() {
return
}

// Get diff information.

ctx.HTML(200, COMPARE_PULL) ctx.HTML(200, COMPARE_PULL)
} }




+ 1
- 1
templates/repo/commits_table.tmpl View File

@@ -10,7 +10,7 @@
</form> </form>
</div> </div>
{{else if .IsDiffCompare}} {{else if .IsDiffCompare}}
<a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="ui green sha label">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="ui green sha label">{{ShortSha .AfterCommitId}}</a>
<a href="{{$.RepoLink}}/commit/{{.BeforeCommitID}}" class="ui green sha label">{{ShortSha .BeforeCommitID}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitID}}" class="ui green sha label">{{ShortSha .AfterCommitID}}</a>
{{end}} {{end}}
</h4> </h4>
<div class="ui attached table segment"> <div class="ui attached table segment">


+ 3
- 1
templates/repo/diff.tmpl View File

@@ -24,6 +24,7 @@
<span class="text grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span> <span class="text grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span>
<div class="ui right"> <div class="ui right">
<div class="ui horizontal list"> <div class="ui horizontal list">
{{if .Parents}}
<div class="item"> <div class="item">
{{.i18n.Tr "repo.diff.parent"}} {{.i18n.Tr "repo.diff.parent"}}
</div> </div>
@@ -32,8 +33,9 @@
<a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a> <a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a>
{{end}} {{end}}
</div> </div>
{{end}}
<div class="item">{{.i18n.Tr "repo.diff.commit"}}</div> <div class="item">{{.i18n.Tr "repo.diff.commit"}}</div>
<div class="item"><span class="ui blue sha label">{{ShortSha .CommitId}}</span></div>
<div class="item"><span class="ui blue sha label">{{ShortSha .CommitID}}</span></div>
</div> </div>
</div> </div>
</div> </div>


+ 4
- 0
templates/repo/issue/new_form.tmpl View File

@@ -18,7 +18,11 @@
{{template "repo/issue/comment_tab" .}} {{template "repo/issue/comment_tab" .}}
<div class="text right"> <div class="text right">
<button class="ui green button"> <button class="ui green button">
{{if .PageIsComparePull}}
{{.i18n.Tr "repo.pulls.create"}}
{{else}}
{{.i18n.Tr "repo.issues.create"}} {{.i18n.Tr "repo.issues.create"}}
{{end}}
</button> </button>
</div> </div>
</div> </div>


+ 1
- 1
templates/repo/view_file.tmpl View File

@@ -13,7 +13,7 @@
{{end}} {{end}}
{{if not .ReadmeInList}} {{if not .ReadmeInList}}
{{if not .IsCommit}} {{if not .IsCommit}}
<a class="right" href="{{.RepoLink}}/src/{{.CommitId}}/{{EscapePound .TreeName}}">
<a class="right" href="{{.RepoLink}}/src/{{.CommitID}}/{{EscapePound .TreeName}}">
<button class="btn btn-medium btn-gray btn-right-radius btn-comb">{{.i18n.Tr "repo.file_permalink"}}</button> <button class="btn btn-medium btn-gray btn-right-radius btn-comb">{{.i18n.Tr "repo.file_permalink"}}</button>
</a> </a>
{{end}} {{end}}


Loading…
Cancel
Save