Browse Source

rename fields

for-closed-social
Unknwon 9 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_desc = Compare two branches and make a pull request for changes.
pulls.no_results = No results found.
pulls.create = Create Pull Request
milestones.new = New Milestone
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
TagName string
TreeName string
CommitId string
CommitID string
RepoLink string
CloneLink models.CloneLink
CommitsCount int

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

@ -118,7 +118,7 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfBranch", err)
return
}
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
ctx.Repo.IsBranch = true
} else {
@ -149,7 +149,7 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfBranch", err)
return
}
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
} else if ctx.Repo.GitRepo.IsTagExist(refName) {
ctx.Repo.IsTag = true
@ -158,10 +158,10 @@ func RepoRef() macaron.Handler {
ctx.Handle(500, "GetCommitOfTag", err)
return
}
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
} else if len(refName) == 40 {
ctx.Repo.IsCommit = true
ctx.Repo.CommitId = refName
ctx.Repo.CommitID = refName
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommit(refName)
if err != nil {
@ -176,7 +176,7 @@ func RepoRef() macaron.Handler {
ctx.Repo.BranchName = refName
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["IsTag"] = ctx.Repo.IsTag
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["CommitId"] = ctx.Repo.CommitId
ctx.Data["CommitID"] = ctx.Repo.CommitID
userAgent := ctx.Req.Header.Get("User-Agent")
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
repoName := ctx.Repo.Repository.Name
commitId := ctx.Repo.CommitId
commitID := ctx.Repo.CommitID
commit := ctx.Repo.Commit
commit.CommitMessage = commit.CommitMessage
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName),
commitId, setting.Git.MaxGitDiffLines)
commitID, setting.Git.MaxGitDiffLines)
if err != nil {
ctx.Handle(404, "GetDiffCommit", err)
return
@ -236,17 +236,17 @@ func Diff(ctx *middleware.Context) {
ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName
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["Author"] = models.ValidateCommitWithEmail(commit)
ctx.Data["Diff"] = diff
ctx.Data["Parents"] = parents
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 {
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)
}
@ -255,17 +255,17 @@ func CompareDiff(ctx *middleware.Context) {
ctx.Data["IsDiffCompare"] = true
userName := ctx.Repo.Owner.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 {
ctx.Handle(404, "GetCommit", err)
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 {
ctx.Handle(404, "GetDiffRange", err)
return
@ -290,7 +290,7 @@ func CompareDiff(ctx *middleware.Context) {
return isImage
}
commits, err := commit.CommitsBeforeUntil(beforeCommitId)
commits, err := commit.CommitsBeforeUntil(beforeCommitID)
if err != nil {
ctx.Handle(500, "CommitsBeforeUntil", err)
return
@ -299,17 +299,17 @@ func CompareDiff(ctx *middleware.Context) {
ctx.Data["Commits"] = commits
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["Reponame"] = repoName
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["Diff"] = diff
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)
}

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

@ -190,39 +190,46 @@ func renderAttachmentSettings(ctx *middleware.Context) {
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) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["RequireDropzone"] = true
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)
@ -240,16 +247,18 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
milestoneID int64
assigneeID int64
attachments []string
err error
)
if ctx.Repo.IsAdmin() {
labels := RetrieveRepoMetas(ctx, repo)
if ctx.Written() {
return
}
// Check labels.
labelIDs = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
labelIDMark := base.Int64sToMap(labelIDs)
labels, err := models.GetLabelsByRepoID(repo.ID)
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID: %v", err)
return
}
hasSelected := false
for i := range labels {
if labelIDMark[labels[i].ID] {
@ -264,16 +273,6 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
// Check milestone.
milestoneID = form.MilestoneID
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)
if err != nil {
ctx.Handle(500, "GetMilestoneByID: %v", err)
@ -285,11 +284,6 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
// Check assignee.
assigneeID = form.AssigneeID
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)
if err != nil {
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)
if err != nil {
ctx.Data["Err_RepoName"] = true
switch {
case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), FORK, &form)
case models.IsErrNameReserved(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(models.ErrNameReserved).Name), FORK, &form)
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)
default:
ctx.Handle(500, "ForkPost", err)
@ -120,7 +118,12 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
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("*"), "...")
if len(infos) != 2 {
ctx.Handle(404, "CompareAndPullRequest", nil)
@ -144,7 +147,7 @@ func CompareAndPullRequest(ctx *middleware.Context) {
// TODO: add organization support
// 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 {
ctx.Handle(404, "HasForkedRepo", nil)
return
@ -162,6 +165,14 @@ func CompareAndPullRequest(ctx *middleware.Context) {
}
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)
}

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

@ -10,7 +10,7 @@
</form>
</div>
{{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}}
</h4>
<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>
<div class="ui right">
<div class="ui horizontal list">
{{if .Parents}}
<div class="item">
{{.i18n.Tr "repo.diff.parent"}}
</div>
@ -32,8 +33,9 @@
<a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a>
{{end}}
</div>
{{end}}
<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>

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

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

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

@ -13,7 +13,7 @@
{{end}}
{{if not .ReadmeInList}}
{{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>
</a>
{{end}}

Loading…
Cancel
Save