Fix fork repo and macaron API broken
This commit is contained in:
parent
baae94b9cf
commit
f1d8746264
8 changed files with 171 additions and 178 deletions
|
@ -149,7 +149,7 @@ func DelLoginSource(source *LoginSource) error {
|
|||
|
||||
// UserSignIn validates user name and password.
|
||||
func UserSignIn(uname, passwd string) (*User, error) {
|
||||
var u *User
|
||||
u := new(User)
|
||||
if strings.Contains(uname, "@") {
|
||||
u = &User{Email: uname}
|
||||
} else {
|
||||
|
|
|
@ -1424,7 +1424,7 @@ func ForkRepository(u *User, oldRepo *Repository) (*Repository, error) {
|
|||
repoPath := RepoPath(u.Name, repo.Name)
|
||||
_, stderr, err := process.ExecTimeout(10*time.Minute,
|
||||
fmt.Sprintf("ForkRepository(git clone): %s/%s", u.Name, repo.Name),
|
||||
"git", "clone", oldRepoPath, repoPath)
|
||||
"git", "clone", "--bare", oldRepoPath, repoPath)
|
||||
if err != nil {
|
||||
return nil, errors.New("ForkRepository(git clone): " + stderr)
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ func IsEmailUsed(email string) (bool, error) {
|
|||
return x.Get(&User{Email: email})
|
||||
}
|
||||
|
||||
// GetUserSalt returns a user salt token
|
||||
// GetUserSalt returns a ramdom user salt token.
|
||||
func GetUserSalt() string {
|
||||
return base.GetRandomString(10)
|
||||
}
|
||||
|
@ -473,19 +473,19 @@ func GetUserById(id int64) (*User, error) {
|
|||
return u, nil
|
||||
}
|
||||
|
||||
// GetUserByName returns the user object by given name if exists.
|
||||
// GetUserByName returns user by given name.
|
||||
func GetUserByName(name string) (*User, error) {
|
||||
if len(name) == 0 {
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
user := &User{LowerName: strings.ToLower(name)}
|
||||
has, err := x.Get(user)
|
||||
u := &User{LowerName: strings.ToLower(name)}
|
||||
has, err := x.Get(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
return user, nil
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetUserEmailsByNames returns a list of e-mails corresponds to names.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue