Browse Source

PR: simple work

pull/1007/head
Unknwon 10 years ago
parent
commit
251e360e34
  1. 4
      cmd/web.go
  2. 4
      conf/locale/locale_en-US.ini
  3. 2
      gogs.go
  4. 23
      routers/repo/pull.go
  5. 2
      templates/.VERSION
  6. 10
      templates/repo/home.tmpl
  7. 41
      templates/repo/pull_new.tmpl

4
cmd/web.go

@ -393,6 +393,10 @@ func runWeb(ctx *cli.Context) {
m.Post("/:name", repo.GitHooksEditPost)
}, middleware.GitHookService())
})
m.Group("/pulls", func() {
m.Combo("/new").Get(repo.NewPullRequest)
})
}, reqSignIn, middleware.RepoAssignment(true), reqAdmin)
m.Group("/:username/:reponame", func() {

4
conf/locale/locale_en-US.ini

@ -413,6 +413,10 @@ release.save_draft = Save Draft
release.edit_release = Edit Release
release.tag_name_already_exist = Release with this tag name has already existed.
pulls.new = New Pull Request
pulls.request_from = Request From
pulls.request_to = Request To
[org]
org_name_holder = Organization Name
org_name_helper = Great organization names are short and memorable.

2
gogs.go

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.5.16.0301 Beta"
const APP_VER = "0.5.17.0304 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

23
routers/repo/pull.go

@ -11,9 +11,32 @@ import (
const (
PULLS base.TplName = "repo/pulls"
NEW_PULL base.TplName = "repo/pull_new"
)
func Pulls(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarPulls"] = true
ctx.HTML(200, PULLS)
}
func NewPullRequest(ctx *middleware.Context) {
repo := ctx.Repo.Repository
if !repo.IsFork {
ctx.Redirect(ctx.Repo.RepoLink)
return
}
ctx.Data["RequestFrom"] = repo.Owner.Name + "/" + repo.Name
if err := ctx.Repo.Repository.GetForkRepo(); err != nil {
ctx.Handle(500, "GetForkRepo", err)
return
}
forkRepo := ctx.Repo.Repository.ForkRepo
if err := forkRepo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", err)
return
}
ctx.Data["RequestTo"] = forkRepo.Owner.Name + "/" + forkRepo.Name
ctx.HTML(200, NEW_PULL)
}

2
templates/.VERSION

@ -1 +1 @@
0.5.16.0301 Beta
0.5.17.0304 Beta

10
templates/repo/home.tmpl

@ -9,11 +9,13 @@
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
</p>
<ul id="repo-file-nav" class="clear menu menu-line">
<!-- <li>
<a href="#">
<button class="btn btn-green btn-small btn-radius" id="repo-compare-btn"><i class="octicon octicon-git-compare"></i></button>
{{if (and (.Repository.IsFork) .IsRepositoryAdmin)}}
<li>
<a href="{{.RepoLink}}/pulls/new">
<button class="btn btn-green btn-small btn-radius" id="repo-compare-btn"><i class="octicon octicon-git-pull-request"></i></button>
</a>
</li> -->
</li>
{{end}}
<li id="repo-branch-switch" class="down drop">
<a>
<button class="btn btn-gray btn-medium btn-radius">

41
templates/repo/pull_new.tmpl

@ -0,0 +1,41 @@
{{template "ng/base/head" .}}
{{template "ng/base/header" .}}
<div id="repo-wrapper">
<form id="repo-create-form" class="form form-align panel panel-radius" action="{{AppSubUrl}}{{.RepoLink}}/pull/new" method="post">
{{.CsrfTokenHtml}}
<div class="panel-header">
<h2>{{.i18n.Tr "repo.pulls.new"}}</h2>
</div>
<div class="panel-content">
{{template "ng/base/alert" .}}
<div class="field">
<label>{{.i18n.Tr "repo.pulls.request_from"}}</label>
<span><a target="_blank" href="{{AppSubUrl}}/{{.RequestFrom}}">{{.RequestFrom}}</a></span>
</div>
<div class="field">
<label for="from_branch" class="req">{{.i18n.Tr "repo.pulls.from_branch"}}</label>
<input id="from_branch_name" type="hidden" name="branch_name" value="{{.BranchName}}" />
<div class="inline-block drop">
<a class="drop-bottom">
<strong id="branch-name">{{.BranchName}}</strong>
</a>
<ul class="drop-down menu menu-vertical menu-radius switching-list" id="repo-create-owner-list">
{{range .Branches}}
<li {{if eq . $.BranchName}}class="checked"{{end}} data-branch-name="{{.}}">
<a>
<i class="octicon octicon-check"></i>
<strong>{{.}}</strong>
</a>
</li>
{{end}}
</ul>
</div>
</div>
<div class="field">
<label>{{.i18n.Tr "repo.pulls.request_to"}}</label>
<span><a target="_blank" href="{{AppSubUrl}}/{{.RequestTo}}">{{.RequestTo}}</a></span>
</div>
</div>
</form>
</div>
{{template "ng/base/footer" .}}
Loading…
Cancel
Save