Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
0dfb5560cd
|
@ -40,6 +40,7 @@ type Action struct {
|
||||||
RepoId int64
|
RepoId int64
|
||||||
RepoName string
|
RepoName string
|
||||||
RefName string
|
RefName string
|
||||||
|
IsPrivate bool `xorm:"not null"`
|
||||||
Content string `xorm:"TEXT"`
|
Content string `xorm:"TEXT"`
|
||||||
Created time.Time `xorm:"created"`
|
Created time.Time `xorm:"created"`
|
||||||
}
|
}
|
||||||
|
@ -100,13 +101,12 @@ func CommitRepoAction(userId int64, userName, actEmail string,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !repo.IsPrivate {
|
|
||||||
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
|
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
|
||||||
OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
|
OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName,
|
||||||
|
IsPrivate: repo.IsPrivate}); err != nil {
|
||||||
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
|
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName)
|
log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName)
|
||||||
return nil
|
return nil
|
||||||
|
@ -114,12 +114,8 @@ func CommitRepoAction(userId int64, userName, actEmail string,
|
||||||
|
|
||||||
// NewRepoAction adds new action for creating repository.
|
// NewRepoAction adds new action for creating repository.
|
||||||
func NewRepoAction(user *User, repo *Repository) (err error) {
|
func NewRepoAction(user *User, repo *Repository) (err error) {
|
||||||
if repo.IsPrivate {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
|
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
|
||||||
OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil {
|
OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name, IsPrivate: repo.IsPrivate}); err != nil {
|
||||||
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -130,12 +126,9 @@ func NewRepoAction(user *User, repo *Repository) (err error) {
|
||||||
|
|
||||||
// TransferRepoAction adds new action for transfering repository.
|
// TransferRepoAction adds new action for transfering repository.
|
||||||
func TransferRepoAction(user, newUser *User, repo *Repository) (err error) {
|
func TransferRepoAction(user, newUser *User, repo *Repository) (err error) {
|
||||||
if repo.IsPrivate {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
|
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
|
||||||
OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name}); err != nil {
|
OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name,
|
||||||
|
IsPrivate: repo.IsPrivate}); err != nil {
|
||||||
log.Error("action.TransferRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
log.Error("action.TransferRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -149,7 +142,7 @@ func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) {
|
||||||
actions := make([]Action, 0, 20)
|
actions := make([]Action, 0, 20)
|
||||||
sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid)
|
sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid)
|
||||||
if isProfile {
|
if isProfile {
|
||||||
sess.And("act_user_id=?", userid)
|
sess.Where("is_private=?", false).And("act_user_id=?", userid)
|
||||||
} else {
|
} else {
|
||||||
sess.And("act_user_id!=?", userid)
|
sess.And("act_user_id!=?", userid)
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,16 +310,14 @@ func CreateRepository(user *User, name, desc, lang, license string, private, mir
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !repo.IsPrivate {
|
|
||||||
if err = NewRepoAction(user, repo); err != nil {
|
|
||||||
log.Error("repo.CreateRepository(NewRepoAction): %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = WatchRepo(user.Id, repo.Id, true); err != nil {
|
if err = WatchRepo(user.Id, repo.Id, true); err != nil {
|
||||||
log.Error("repo.CreateRepository(WatchRepo): %v", err)
|
log.Error("repo.CreateRepository(WatchRepo): %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = NewRepoAction(user, repo); err != nil {
|
||||||
|
log.Error("repo.CreateRepository(NewRepoAction): %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// No need for init for mirror.
|
// No need for init for mirror.
|
||||||
if mirror {
|
if mirror {
|
||||||
return repo, nil
|
return repo, nil
|
||||||
|
|
|
@ -230,11 +230,11 @@ func ChangeUserName(user *User, newUserName string) (err error) {
|
||||||
accesses[i].UserName = newUserName
|
accesses[i].UserName = newUserName
|
||||||
if strings.HasPrefix(accesses[i].RepoName, user.LowerName+"/") {
|
if strings.HasPrefix(accesses[i].RepoName, user.LowerName+"/") {
|
||||||
accesses[i].RepoName = strings.Replace(accesses[i].RepoName, user.LowerName, newUserName, 1)
|
accesses[i].RepoName = strings.Replace(accesses[i].RepoName, user.LowerName, newUserName, 1)
|
||||||
|
}
|
||||||
if err = UpdateAccessWithSession(sess, &accesses[i]); err != nil {
|
if err = UpdateAccessWithSession(sess, &accesses[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
repos, err := GetRepositories(user, true)
|
repos, err := GetRepositories(user, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -248,6 +248,7 @@ func ChangeUserName(user *User, newUserName string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for j := range accesses {
|
for j := range accesses {
|
||||||
|
accesses[j].UserName = newUserName
|
||||||
accesses[j].RepoName = newUserName + "/" + repos[i].LowerName
|
accesses[j].RepoName = newUserName + "/" + repos[i].LowerName
|
||||||
if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil {
|
if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue