modes/repo: incorrect SSH clone URL for #742
This commit is contained in:
parent
ac4a10456e
commit
b553ea45ee
6 changed files with 52 additions and 37 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.5.8.1212 Beta"
|
||||
const APP_VER = "0.5.8.1213 Beta"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -241,6 +241,27 @@ func IsRepositoryExist(u *User, repoName string) (bool, error) {
|
|||
return com.IsDir(RepoPath(u.Name, repoName)), nil
|
||||
}
|
||||
|
||||
// CloneLink represents different types of clone URLs of repository.
|
||||
type CloneLink struct {
|
||||
SSH string
|
||||
HTTPS string
|
||||
Git string
|
||||
}
|
||||
|
||||
// CloneLink returns clone URLs of repository.
|
||||
func (repo *Repository) CloneLink() (cl CloneLink, err error) {
|
||||
if err = repo.GetOwner(); err != nil {
|
||||
return cl, err
|
||||
}
|
||||
if setting.SshPort != 22 {
|
||||
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SshPort, repo.Owner.LowerName, repo.LowerName)
|
||||
} else {
|
||||
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, repo.Owner.LowerName, repo.LowerName)
|
||||
}
|
||||
cl.HTTPS = fmt.Sprintf("%s%s/%s.git", setting.AppUrl, repo.Owner.LowerName, repo.LowerName)
|
||||
return cl, nil
|
||||
}
|
||||
|
||||
var (
|
||||
illegalEquals = []string{"debug", "raw", "install", "api", "avatar", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "new"}
|
||||
illegalSuffixs = []string{".git", ".keys"}
|
||||
|
|
|
@ -39,29 +39,25 @@ type Context struct {
|
|||
IsBasicAuth bool
|
||||
|
||||
Repo struct {
|
||||
IsOwner bool
|
||||
IsTrueOwner bool
|
||||
IsWatching bool
|
||||
IsBranch bool
|
||||
IsTag bool
|
||||
IsCommit bool
|
||||
IsAdmin bool // Current user is admin level.
|
||||
HasAccess bool
|
||||
Repository *models.Repository
|
||||
Owner *models.User
|
||||
Commit *git.Commit
|
||||
Tag *git.Tag
|
||||
GitRepo *git.Repository
|
||||
BranchName string
|
||||
TagName string
|
||||
TreeName string
|
||||
CommitId string
|
||||
RepoLink string
|
||||
CloneLink struct {
|
||||
SSH string
|
||||
HTTPS string
|
||||
Git string
|
||||
}
|
||||
IsOwner bool
|
||||
IsTrueOwner bool
|
||||
IsWatching bool
|
||||
IsBranch bool
|
||||
IsTag bool
|
||||
IsCommit bool
|
||||
IsAdmin bool // Current user is admin level.
|
||||
HasAccess bool
|
||||
Repository *models.Repository
|
||||
Owner *models.User
|
||||
Commit *git.Commit
|
||||
Tag *git.Tag
|
||||
GitRepo *git.Repository
|
||||
BranchName string
|
||||
TagName string
|
||||
TreeName string
|
||||
CommitId string
|
||||
RepoLink string
|
||||
CloneLink models.CloneLink
|
||||
CommitsCount int
|
||||
Mirror *models.Mirror
|
||||
}
|
||||
|
|
|
@ -386,12 +386,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
|
||||
ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner
|
||||
|
||||
if setting.SshPort != 22 {
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SshPort, u.LowerName, repo.LowerName)
|
||||
} else {
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, u.LowerName, repo.LowerName)
|
||||
ctx.Repo.CloneLink, err = repo.CloneLink()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "CloneLink", err)
|
||||
return
|
||||
}
|
||||
ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s%s/%s.git", setting.AppUrl, u.LowerName, repo.LowerName)
|
||||
ctx.Data["CloneLink"] = ctx.Repo.CloneLink
|
||||
|
||||
if ctx.Repo.Repository.IsGoget {
|
||||
|
|
|
@ -23,20 +23,19 @@ import (
|
|||
|
||||
// ToApiRepository converts repository to API format.
|
||||
func ToApiRepository(owner *models.User, repo *models.Repository, permission api.Permission) *api.Repository {
|
||||
sshUrlFmt := "%s@%s:%s/%s.git"
|
||||
if setting.SshPort != 22 {
|
||||
sshUrlFmt = "ssh://%s@%s:%d/%s/%s.git"
|
||||
cl, err := repo.CloneLink()
|
||||
if err != nil {
|
||||
log.Error(4, "CloneLink: %v", err)
|
||||
}
|
||||
htmlUrl := setting.AppUrl + owner.Name + "/" + repo.Name
|
||||
return &api.Repository{
|
||||
Id: repo.Id,
|
||||
Owner: *ToApiUser(owner),
|
||||
FullName: owner.Name + "/" + repo.Name,
|
||||
Private: repo.IsPrivate,
|
||||
Fork: repo.IsFork,
|
||||
HtmlUrl: htmlUrl,
|
||||
SshUrl: fmt.Sprintf(sshUrlFmt, setting.RunUser, setting.Domain, owner.LowerName, repo.LowerName),
|
||||
CloneUrl: htmlUrl + ".git",
|
||||
HtmlUrl: setting.AppUrl + owner.Name + "/" + repo.Name,
|
||||
CloneUrl: cl.HTTPS,
|
||||
SshUrl: cl.SSH,
|
||||
Permissions: permission,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.5.8.1212 Beta
|
||||
0.5.8.1213 Beta
|
Loading…
Reference in a new issue