improve fork process

pull/197/head
Unknwon 9 years ago
parent e6862e9cec
commit 9db4acc62e
  1. 4
      cmd/web.go
  2. 2
      conf/locale/locale_en-US.ini
  3. 14
      models/error.go
  4. 129
      models/repo.go
  5. 5
      modules/base/template.go
  6. 8
      modules/bindata/bindata.go
  7. 2
      public/css/gogs.min.css
  8. 6
      public/less/_base.less
  9. 34
      public/less/_form.less
  10. 2
      routers/api/v1/repo.go
  11. 95
      routers/repo/pull.go
  12. 113
      routers/repo/repo.go
  13. 4
      routers/repo/setting.go
  14. 65
      templates/repo/fork.tmpl
  15. 2
      templates/repo/header.tmpl
  16. 2
      templates/repo/header_old.tmpl
  17. 69
      templates/repo/pulls/fork.tmpl

@ -383,8 +383,8 @@ func runWeb(ctx *cli.Context) {
m.Post("/create", bindIgnErr(auth.CreateRepoForm{}), repo.CreatePost)
m.Get("/migrate", repo.Migrate)
m.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), repo.MigratePost)
m.Get("/fork", repo.Fork)
m.Post("/fork", bindIgnErr(auth.CreateRepoForm{}), repo.ForkPost)
m.Combo("/fork/:repoid").Get(repo.Fork).
Post(bindIgnErr(auth.CreateRepoForm{}), repo.ForkPost)
}, reqSignIn)
m.Group("/:username/:reponame", func() {

@ -300,7 +300,7 @@ owner = Owner
repo_name = Repository Name
repo_name_helper = A good repository name is usually composed of short, memorable and unique keywords.
visibility = Visibility
visiblity_helper = This repository is <span class="label label-red label-radius">Private</span>
visiblity_helper = This repository is <span class="ui red text">Private</span>
fork_repo = Fork Repository
fork_from = Fork From
fork_visiblity_helper = You cannot alter the visibility of a forked repository.

@ -225,6 +225,20 @@ func (err ErrRepoNotExist) Error() string {
return fmt.Sprintf("repository does not exist [id: %d, uid: %d, name: %s]", err.ID, err.UID, err.Name)
}
type ErrRepoAlreadyExist struct {
Uname string
Name string
}
func IsErrRepoAlreadyExist(err error) bool {
_, ok := err.(ErrRepoAlreadyExist)
return ok
}
func (err ErrRepoAlreadyExist) Error() string {
return fmt.Sprintf("repository already exists [uname: %d, name: %s]", err.Uname, err.Name)
}
// _____ .__.__ __
// / \ |__| | ____ _______/ |_ ____ ____ ____
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \

@ -21,6 +21,7 @@ import (
"github.com/Unknwon/cae/zip"
"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/bindata"
@ -35,7 +36,6 @@ const (
)
var (
ErrRepoAlreadyExist = errors.New("Repository already exist")
ErrRepoFileNotExist = errors.New("Repository file does not exist")
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
ErrMirrorNotExist = errors.New("Mirror does not exist")
@ -222,15 +222,19 @@ func (repo *Repository) DescriptionHtml() template.HTML {
return template.HTML(DescPattern.ReplaceAllStringFunc(base.Sanitizer.Sanitize(repo.Description), sanitize))
}
// IsRepositoryExist returns true if the repository with given name under user has already existed.
func IsRepositoryExist(u *User, repoName string) (bool, error) {
has, err := x.Get(&Repository{
func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) {
has, err := e.Get(&Repository{
OwnerId: u.Id,
LowerName: strings.ToLower(repoName),
})
return has && com.IsDir(RepoPath(u.Name, repoName)), err
}
// IsRepositoryExist returns true if the repository with given name under user has already existed.
func IsRepositoryExist(u *User, repoName string) (bool, error) {
return isRepositoryExist(x, u, repoName)
}
// CloneLink represents different types of clone URLs of repository.
type CloneLink struct {
SSH string
@ -525,19 +529,50 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, initRe
return initRepoCommit(tmpDir, u.NewGitSig())
}
// CreateRepository creates a repository for given user or organization.
func CreateRepository(u *User, name, desc, lang, license string, isPrivate, isMirror, initReadme bool) (_ *Repository, err error) {
if err = IsUsableName(name); err != nil {
return nil, err
func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
if err = IsUsableName(repo.Name); err != nil {
return err
}
has, err := IsRepositoryExist(u, name)
has, err := isRepositoryExist(e, u, repo.Name)
if err != nil {
return nil, fmt.Errorf("IsRepositoryExist: %v", err)
return fmt.Errorf("IsRepositoryExist: %v", err)
} else if has {
return nil, ErrRepoAlreadyExist
return ErrRepoAlreadyExist{u.Name, repo.Name}
}
if _, err = e.Insert(repo); err != nil {
return err
} else if _, err = e.Exec("UPDATE `user` SET num_repos=num_repos+1 WHERE id=?", u.Id); err != nil {
return err
}
// Give access to all members in owner team.
if u.IsOrganization() {
t, err := u.getOwnerTeam(e)
if err != nil {
return fmt.Errorf("getOwnerTeam: %v", err)
} else if err = t.addRepository(e, repo); err != nil {
return fmt.Errorf("addRepository: %v", err)
}
} else {
// Organization automatically called this in addRepository method.
if err = repo.recalculateAccesses(e); err != nil {
return fmt.Errorf("recalculateAccesses: %v", err)
}
}
if err = watchRepo(e, u.Id, repo.Id, true); err != nil {
return fmt.Errorf("watchRepo: %v", err)
} else if err = newRepoAction(e, u, repo); err != nil {
return fmt.Errorf("newRepoAction: %v", err)
}
return nil
}
// CreateRepository creates a repository for given user or organization.
func CreateRepository(u *User, name, desc, lang, license string, isPrivate, isMirror, initReadme bool) (_ *Repository, err error) {
repo := &Repository{
OwnerId: u.Id,
Owner: u,
@ -553,35 +588,10 @@ func CreateRepository(u *User, name, desc, lang, license string, isPrivate, isMi
return nil, err
}
if _, err = sess.Insert(repo); err != nil {
return nil, err
} else if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", u.Id); err != nil {
if err = createRepository(sess, u, repo); err != nil {
return nil, err
}
// TODO fix code for mirrors?
// Give access to all members in owner team.
if u.IsOrganization() {
t, err := u.getOwnerTeam(sess)
if err != nil {
return nil, fmt.Errorf("getOwnerTeam: %v", err)
} else if err = t.addRepository(sess, repo); err != nil {
return nil, fmt.Errorf("addRepository: %v", err)
}
} else {
// Organization called this in addRepository method.
if err = repo.recalculateAccesses(sess); err != nil {
return nil, fmt.Errorf("recalculateAccesses: %v", err)
}
}
if err = watchRepo(sess, u.Id, repo.Id, true); err != nil {
return nil, fmt.Errorf("watchRepo: %v", err)
} else if err = newRepoAction(sess, u, repo); err != nil {
return nil, fmt.Errorf("newRepoAction: %v", err)
}
// No need for init mirror.
if !isMirror {
repoPath := RepoPath(u.Name, repo.Name)
@ -649,7 +659,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
if err != nil {
return fmt.Errorf("IsRepositoryExist: %v", err)
} else if has {
return ErrRepoAlreadyExist
return ErrRepoAlreadyExist{newOwnerName, repo.Name}
}
sess := x.NewSession()
@ -767,7 +777,7 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
if err != nil {
return fmt.Errorf("IsRepositoryExist: %v", err)
} else if has {
return ErrRepoAlreadyExist
return ErrRepoAlreadyExist{u.Name, newRepoName}
}
// Change repository directory name.
@ -1412,21 +1422,6 @@ func IsStaring(uid, repoId int64) bool {
// \/ \/
func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
has, err := IsRepositoryExist(u, name)
if err != nil {
return nil, fmt.Errorf("IsRepositoryExist: %v", err)
} else if has {
return nil, ErrRepoAlreadyExist
}
// In case the old repository is a fork.
if oldRepo.IsFork {
oldRepo, err = GetRepositoryById(oldRepo.ForkId)
if err != nil {
return nil, err
}
}
repo := &Repository{
OwnerId: u.Id,
Owner: u,
@ -1444,34 +1439,10 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
return nil, err
}
if _, err = sess.Insert(repo); err != nil {
if err = createRepository(sess, u, repo); err != nil {
return nil, err
}
if err = repo.recalculateAccesses(sess); err != nil {
return nil, err
} else if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", u.Id); err != nil {
return nil, err
}
if u.IsOrganization() {
// Update owner team info and count.
t, err := u.getOwnerTeam(sess)
if err != nil {
return nil, fmt.Errorf("getOwnerTeam: %v", err)
} else if err = t.addRepository(sess, repo); err != nil {
return nil, fmt.Errorf("addRepository: %v", err)
}
} else {
if err = watchRepo(sess, u.Id, repo.Id, true); err != nil {
return nil, fmt.Errorf("watchRepo: %v", err)
}
}
if err = newRepoAction(sess, u, repo); err != nil {
return nil, fmt.Errorf("newRepoAction: %v", err)
}
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", oldRepo.Id); err != nil {
return nil, err
}

@ -20,6 +20,10 @@ import (
"github.com/gogits/gogs/modules/setting"
)
func Safe(raw string) template.HTML {
return template.HTML(raw)
}
func Str2html(raw string) template.HTML {
return template.HTML(Sanitizer.Sanitize(raw))
}
@ -128,6 +132,7 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
},
"AvatarLink": AvatarLink,
"Safe": Safe,
"Str2html": Str2html,
"TimeSince": TimeSince,
"FileSize": FileSize,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -62,6 +62,12 @@ img {
&.right {
float: right;
}
.text {
&.red {
color: #d95c5c!important;
}
}
}
footer {
margin-top: @footer-margin!important;

@ -11,4 +11,38 @@
.right {
margin-top: -5px;
}
}
.repository form {
margin: auto;
width: 800px!important;
.ui.message {
text-align: center;
}
@input-padding: 250px !important;
.header {
padding-left: @input-padding+20px;
}
.inline.field > label {
text-align: right;
width: @input-padding;
word-wrap: break-word;
}
.help {
margin-left: @input-padding+10px;
}
.dropdown {
.dropdown.icon {
margin-top: -7px!important;
}
.text {
margin-right: 0!important;
i {
margin-right: 0!important;
}
}
}
input,
textarea {
width: 50%!important;
}
}

@ -104,7 +104,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
repo, err := models.CreateRepository(owner, opt.Name, opt.Description,
opt.Gitignore, opt.License, opt.Private, false, opt.AutoInit)
if err != nil {
if err == models.ErrRepoAlreadyExist ||
if models.IsErrRepoAlreadyExist(err) ||
models.IsErrNameReserved(err) ||
models.IsErrNamePatternNotAllowed(err) {
ctx.JSON(422, &base.ApiJsonErr{err.Error(), base.DOC_URL})

@ -5,14 +5,109 @@
package repo
import (
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
)
const (
FORK base.TplName = "repo/pulls/fork"
PULLS base.TplName = "repo/pulls"
)
func getForkRepository(ctx *middleware.Context) *models.Repository {
forkRepo, err := models.GetRepositoryById(ctx.ParamsInt64(":repoid"))
if err != nil {
if models.IsErrRepoNotExist(err) {
ctx.Handle(404, "GetRepositoryById", nil)
} else {
ctx.Handle(500, "GetRepositoryById", err)
}
return nil
}
ctx.Data["repo_name"] = forkRepo.Name
ctx.Data["desc"] = forkRepo.Description
ctx.Data["IsPrivate"] = forkRepo.IsPrivate
if err = forkRepo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", err)
return nil
}
ctx.Data["ForkFrom"] = forkRepo.Owner.Name + "/" + forkRepo.Name
if err := ctx.User.GetOrganizations(); err != nil {
ctx.Handle(500, "GetOrganizations", err)
return nil
}
ctx.Data["Orgs"] = ctx.User.Orgs
return forkRepo
}
func Fork(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("new_fork")
getForkRepository(ctx)
if ctx.Written() {
return
}
ctx.Data["ContextUser"] = ctx.User
ctx.HTML(200, FORK)
}
func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
ctx.Data["Title"] = ctx.Tr("new_fork")
forkRepo := getForkRepository(ctx)
if ctx.Written() {
return
}
ctxUser := checkContextUser(ctx, form.Uid)
if ctx.Written() {
return
}
ctx.Data["ContextUser"] = ctxUser
if ctx.HasError() {
ctx.HTML(200, FORK)
return
}
// Check ownership of organization.
if ctxUser.IsOrganization() {
if !ctxUser.IsOwnedBy(ctx.User.Id) {
ctx.Error(403)
return
}
}
repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description)
if err != nil {
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)
}
return
}
log.Trace("Repository forked[%d]: %s/%s", forkRepo.Id, ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
}
func Pulls(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarPulls"] = true
ctx.HTML(200, PULLS)

@ -25,7 +25,6 @@ import (
const (
CREATE base.TplName = "repo/create"
MIGRATE base.TplName = "repo/migrate"
FORK base.TplName = "repo/fork"
)
func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
@ -119,7 +118,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
switch {
case err == models.ErrRepoAlreadyExist:
case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), CREATE, &form)
case models.IsErrNameReserved(err):
@ -222,7 +221,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
switch {
case err == models.ErrRepoAlreadyExist:
case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), MIGRATE, &form)
case models.IsErrNameReserved(err):
@ -236,114 +235,6 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
}
func getForkRepository(ctx *middleware.Context) (*models.Repository, error) {
forkId := ctx.QueryInt64("fork_id")
ctx.Data["ForkId"] = forkId
forkRepo, err := models.GetRepositoryById(forkId)
if err != nil {
return nil, fmt.Errorf("GetRepositoryById: %v", err)
}
ctx.Data["repo_name"] = forkRepo.Name
ctx.Data["desc"] = forkRepo.Description
if err = forkRepo.GetOwner(); err != nil {
return nil, fmt.Errorf("GetOwner: %v", err)
}
ctx.Data["ForkFrom"] = forkRepo.Owner.Name + "/" + forkRepo.Name
return forkRepo, nil
}
func Fork(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("new_fork")
if _, err := getForkRepository(ctx); err != nil {
if models.IsErrRepoNotExist(err) {
ctx.Redirect(setting.AppSubUrl + "/")
} else {
ctx.Handle(500, "getForkRepository", err)
}
return
}
// FIXME: maybe sometime can directly fork to organization?
ctx.Data["ContextUser"] = ctx.User
if err := ctx.User.GetOrganizations(); err != nil {
ctx.Handle(500, "GetOrganizations", err)
return
}
ctx.Data["Orgs"] = ctx.User.Orgs
ctx.HTML(200, FORK)
}
func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
ctx.Data["Title"] = ctx.Tr("new_fork")
forkRepo, err := getForkRepository(ctx)
if err != nil {
if models.IsErrRepoNotExist(err) {
ctx.Redirect(setting.AppSubUrl + "/")
} else {
ctx.Handle(500, "getForkRepository", err)
}
return
}
ctxUser := checkContextUser(ctx, form.Uid)
if ctx.Written() {
return
}
ctx.Data["ContextUser"] = ctxUser
if err := ctx.User.GetOrganizations(); err != nil {
ctx.Handle(500, "GetOrganizations", err)
return
}
ctx.Data["Orgs"] = ctx.User.Orgs
if ctx.HasError() {
ctx.HTML(200, CREATE)
return
}
if ctxUser.IsOrganization() {
// Check ownership of organization.
if !ctxUser.IsOwnedBy(ctx.User.Id) {
ctx.Error(403)
return
}
}
repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description)
if err == nil {
log.Trace("Repository forked: %s/%s", ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
return
}
if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
// FIXME: merge this with other 2 error handling in to one.
switch {
case err == models.ErrRepoAlreadyExist:
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), 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)
}
}
func Action(ctx *middleware.Context) {
var err error
switch ctx.Params(":action") {

@ -56,7 +56,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
if ctx.Repo.Repository.Name != newRepoName {
if err := models.ChangeRepositoryName(ctx.Repo.Owner, ctx.Repo.Repository.Name, newRepoName); err != nil {
switch {
case err == models.ErrRepoAlreadyExist:
case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), SETTINGS_OPTIONS, &form)
case models.IsErrNameReserved(err):
@ -128,7 +128,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
}
if err = models.TransferOwnership(ctx.User, newOwner, ctx.Repo.Repository); err != nil {
if err == models.ErrRepoAlreadyExist {
if models.IsErrRepoAlreadyExist(err) {
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), SETTINGS_OPTIONS, nil)
} else {
ctx.Handle(500, "TransferOwnership", err)

@ -1,65 +0,0 @@
{{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}}/repo/fork?fork_id={{.ForkId}}" method="post">
{{.CsrfTokenHtml}}
<div class="panel-header">
<h2>{{.i18n.Tr "new_fork"}}</h2>
</div>
<div class="panel-content">
{{template "ng/base/alert" .}}
<div class="field">
<label for="owner" class="req">{{.i18n.Tr "repo.owner"}}</label>
<input id="repo-owner-id" type="hidden" name="uid" value="{{.ContextUser.Id}}" />
<div class="inline-block drop">
<a class="drop-bottom">
<img class="avatar" src="{{.ContextUser.AvatarLink}}" id="repo-owner-avatar" alt="user-avatar">
<strong id="repo-owner-name">{{.ContextUser.Name}}</strong>
</a>
<ul class="drop-down menu menu-vertical menu-radius switching-list" id="repo-create-owner-list">
<li {{if eq $.ContextUser.Id .SignedUser.Id}}class="checked"{{end}} data-uid="{{.SignedUser.Id}}">
<a>
<i class="octicon octicon-check"></i>
<img class="avatar" src="{{.SignedUser.AvatarLink}}" alt="user-avatar">
<strong>{{.SignedUser.Name}}</strong>
</a>
</li>
{{range .Orgs}}
<li {{if eq $.ContextUser.Id .Id}}class="checked"{{end}} data-uid="{{.Id}}">
<a>
<i class="octicon octicon-check"></i>
<img class="avatar" src="{{.AvatarLink}}" alt="user-avatar">
<strong>{{.Name}}</strong>
</a>
</li>
{{end}}
</ul>
</div>
</div>
<div class="field">
<label>{{.i18n.Tr "repo.fork_from"}}</label>
<span><a target="_blank" href="{{AppSubUrl}}/{{.ForkFrom}}">{{.ForkFrom}}</a></span>
</div>
<div class="field">
<label class="req" for="repo-name">{{.i18n.Tr "repo.repo_name"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_RepoName}}ipt-error{{end}}" id="repo-name" name="repo_name" type="text" value="{{.repo_name}}" required />
<span class="form-label"></span>
<span class="help">{{.i18n.Tr "repo.repo_name_helper" | Str2html}}</span>
</div>
<div class="field">
<label for="visibility">{{.i18n.Tr "repo.visibility"}}</label>
<span>{{.i18n.Tr "repo.fork_visiblity_helper"}}</span>
</div>
<div class="field clear">
<label class="left" for="desc">{{.i18n.Tr "repo.repo_desc"}}</label>
<textarea class="ipt ipt-large ipt-radius {{if .Err_Description}}ipt-error{{end}}" id="desc" name="desc">{{.desc}}</textarea>
</div>
<div class="field">
<label></label>
<button class="btn btn-large btn-blue btn-radius">{{.i18n.Tr "repo.fork_repo"}}</button>
<a class="btn btn-small btn-gray btn-radius" id="repo-create-cancel" href="{{AppSubUrl}}/"><strong>{{.i18n.Tr "cancel"}}</strong></a>
</div>
</div>
</form>
</div>
{{template "ng/base/footer" .}}

@ -19,7 +19,7 @@
<i class="fa fa-star{{if not $.IsStaringRepo}}-o{{end}}"></i>
{{if $.IsStaringRepo}}{{$.i18n.Tr "repo.unstar"}}{{else}}{{$.i18n.Tr "repo.star"}}{{end}} <span class="num">{{.NumStars}}</span>
</a>
<a class="ui black basic button {{if $.IsRepositoryOwner}}poping up{{end}}" {{if not $.IsRepositoryOwner}}href="{{AppSubUrl}}/repo/fork?fork_id={{.Id}}"{{end}} {{if $.IsRepositoryOwner}}data-content="{{$.i18n.Tr "repo.fork_from_self"}}"{{end}}>
<a class="ui black basic button {{if $.IsRepositoryOwner}}poping up{{end}}" {{if not $.IsRepositoryOwner}}href="{{AppSubUrl}}/repo/fork/{{.Id}}"{{end}} {{if $.IsRepositoryOwner}}data-content="{{$.i18n.Tr "repo.fork_from_self"}}"{{end}}>
<i class="octicon octicon-repo-forked"></i>
{{$.i18n.Tr "repo.fork"}} <span class="num">{{.NumForks}}</span>
</a>

@ -49,7 +49,7 @@
</a>
</li>
<li id="repo-header-fork">
<a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork?fork_id={{.Id}}"{{end}}>
<a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork/{{.Id}}"{{end}}>
<button class="btn btn-gray text-bold btn-radius">
<i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
<span class="num">{{.NumForks}}</span>

@ -0,0 +1,69 @@
{{template "base/head" .}}
<div class="repository new fork">
<div class="ui middle very relaxed page grid">
<div class="column">
<form class="ui form" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
<h3 class="ui top attached header">
{{.i18n.Tr "new_fork"}}
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
<div class="inline required field {{if .Err_Owner}}error{{end}}">
<label>{{.i18n.Tr "repo.owner"}}</label>
<div class="ui selection dropdown">
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.Id}}" required>
<span class="text">
<img class="ui mini avatar image" src="{{.ContextUser.AvatarLink}}">
{{.ContextUser.Name}}
</span>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="{{.SignedUser.Id}}">
<img class="ui mini avatar image" src="{{.SignedUser.AvatarLink}}">
{{.SignedUser.Name}}
</div>
{{range .Orgs}}
<div class="item" data-value="{{.Id}}">
<img class="ui mini avatar image" src="{{.AvatarLink}}">
{{.Name}}
</div>
{{end}}
</div>
</div>
</div>
<div class="inline field">
<label>{{.i18n.Tr "repo.fork_from"}}</label>
<a href="{{AppSubUrl}}/{{.ForkFrom}}">{{.ForkFrom}}</a>
</div>
<div class="inline required field {{if .Err_RepoName}}error{{end}}">
<label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
<input id="repo_name" name="repo_name" value="{{.repo_name}}" required>
</div>
<div class="inline field">
<label>{{.i18n.Tr "repo.visibility"}}</label>
<div class="ui read-only toggle checkbox">
<input type="checkbox" {{if .IsPrivate}}checked{{end}}>
<label>{{.i18n.Tr "repo.visiblity_helper" | Safe}}</label>
</div>
<span class="help">{{.i18n.Tr "repo.fork_visiblity_helper"}}</span>
</div>
<div class="inline field {{if .Err_Description}}error{{end}}">
<label for="desc">{{.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="desc" name="desc">{{.desc}}</textarea>
</div>
<div class="inline field">
<label></label>
<button class="ui green button">
{{.i18n.Tr "repo.fork_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/{{.ForkFrom}}">{{.i18n.Tr "cancel"}}</a>
</div>
</div>
</form>
</div>
</div>
</div>
{{template "base/footer" .}}
Loading…
Cancel
Save