Browse Source

Merge branch 'dev' of github.com:gogits/gogs into dev

pull/384/head
Unknwon 10 years ago
parent
commit
50de06056b
  1. 8
      models/repo.go
  2. 9
      routers/user/setting.go

8
models/repo.go

@ -305,17 +305,17 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
return repo, errors.New("git clone: " + stderr) return repo, errors.New("git clone: " + stderr)
} }
// Pull data from source. // Add remote and fetch data.
if _, stderr, err = process.ExecDir(3*time.Minute, if _, stderr, err = process.ExecDir(3*time.Minute,
tmpDir, fmt.Sprintf("MigrateRepository(git pull): %s", repoPath), tmpDir, fmt.Sprintf("MigrateRepository(git pull): %s", repoPath),
"git", "pull", url); err != nil { "git", "remote", "add", "-f", "--tags", "upstream", url); err != nil {
return repo, errors.New("git pull: " + stderr) return repo, errors.New("git remote: " + stderr)
} }
// Push data to local repository. // Push data to local repository.
if _, stderr, err = process.ExecDir(3*time.Minute, if _, stderr, err = process.ExecDir(3*time.Minute,
tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath), tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath),
"git", "push", "origin", "master"); err != nil { "git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil {
return repo, errors.New("git push: " + stderr) return repo, errors.New("git push: " + stderr)
} }

9
routers/user/setting.go

@ -5,6 +5,8 @@
package user package user
import ( import (
"strings"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
@ -171,7 +173,10 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
return return
} }
if ok, err := models.CheckPublicKeyString(form.Content); !ok { // Remove newline characters from form.KeyContent
cleanContent := strings.Replace(form.Content, "\n", "", -1)
if ok, err := models.CheckPublicKeyString(cleanContent); !ok {
ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
ctx.Redirect("/user/settings/ssh") ctx.Redirect("/user/settings/ssh")
return return
@ -180,7 +185,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
k := &models.PublicKey{ k := &models.PublicKey{
OwnerId: ctx.User.Id, OwnerId: ctx.User.Id,
Name: form.SSHTitle, Name: form.SSHTitle,
Content: form.Content, Content: cleanContent,
} }
if err := models.AddPublicKey(k); err != nil { if err := models.AddPublicKey(k); err != nil {
if err == models.ErrKeyAlreadyExist { if err == models.ErrKeyAlreadyExist {

Loading…
Cancel
Save