output* | output* | ||||
config.codekit | config.codekit | ||||
.brackets.json | .brackets.json | ||||
docker/fig.yml | |||||
docker/docker/Dockerfile | |||||
docker/docker/init_gogs.sh |
r.Get("/logout", user.SignOut) | r.Get("/logout", user.SignOut) | ||||
}) | }) | ||||
m.Get("/user/:username", ignSignIn, user.Profile) // TODO: Legacy | |||||
// FIXME: Legacy | |||||
m.Get("/user/:username", ignSignIn, user.Profile) | |||||
// Gravatar service. | // Gravatar service. | ||||
avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") | avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") |
commit_repo = pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a> | commit_repo = pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a> | ||||
create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a> | create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a> | ||||
comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a> | comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a> | ||||
transfer_repo = transfered repository <code>%s</code> to <a href="%s%s">%s</a> | |||||
[tool] | [tool] | ||||
ago = ago | ago = ago |
commit_repo = 推送了 <a href="%s/%s/src/%s">%s</a> 分支的代码到 <a href="%s/%s">%s</a> | commit_repo = 推送了 <a href="%s/%s/src/%s">%s</a> 分支的代码到 <a href="%s/%s">%s</a> | ||||
create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a> | create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a> | ||||
comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a> | comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a> | ||||
transfer_repo = 将仓库 <code>%s</code> 转移至 <a href="%s%s">%s</a> | |||||
[tool] | [tool] | ||||
ago = 之前 | ago = 之前 |
"github.com/gogits/gogs/modules/setting" | "github.com/gogits/gogs/modules/setting" | ||||
) | ) | ||||
const APP_VER = "0.5.4.0924 Beta" | |||||
const APP_VER = "0.5.4.0925 Beta" | |||||
func init() { | func init() { | ||||
runtime.GOMAXPROCS(runtime.NumCPU()) | runtime.GOMAXPROCS(runtime.NumCPU()) |
// TransferRepoAction adds new action for transfering repository. | // TransferRepoAction adds new action for transfering repository. | ||||
func TransferRepoAction(u, newUser *User, repo *Repository) (err error) { | func TransferRepoAction(u, newUser *User, repo *Repository) (err error) { | ||||
if err = NotifyWatchers(&Action{ActUserId: u.Id, ActUserName: u.Name, ActEmail: u.Email, | if err = NotifyWatchers(&Action{ActUserId: u.Id, ActUserName: u.Name, ActEmail: u.Email, | ||||
OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: repo.Owner.Name, | |||||
RepoName: repo.Name, Content: newUser.Name, | |||||
OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: newUser.Name, | |||||
RepoName: repo.Name, | |||||
IsPrivate: repo.IsPrivate}); err != nil { | IsPrivate: repo.IsPrivate}); err != nil { | ||||
log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name) | log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name) | ||||
return err | return err |
return err | return err | ||||
} | } | ||||
if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName). | |||||
And("user_name = ?", u.LowerName).Update(&Access{UserName: newUser.LowerName}); err != nil { | |||||
sess.Rollback() | |||||
return err | |||||
curRepoLink := path.Join(u.LowerName, repo.LowerName) | |||||
// Delete all access first if current owner is an organization. | |||||
if u.IsOrganization() { | |||||
if _, err = sess.Where("repo_name=?", curRepoLink).Delete(new(Access)); err != nil { | |||||
sess.Rollback() | |||||
return fmt.Errorf("fail to delete current accesses: %v", err) | |||||
} | |||||
} else { | |||||
if _, err = sess.Where("repo_name=?", curRepoLink).And("user_name=?", u.LowerName). | |||||
Update(&Access{UserName: newUser.LowerName}); err != nil { | |||||
sess.Rollback() | |||||
return err | |||||
} | |||||
} | } | ||||
if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName).Update(&Access{ | |||||
RepoName: newUser.LowerName + "/" + repo.LowerName, | |||||
}); err != nil { | |||||
if _, err = sess.Where("repo_name=?", curRepoLink). | |||||
Update(&Access{RepoName: path.Join(newUser.LowerName, repo.LowerName)}); err != nil { | |||||
sess.Rollback() | sess.Rollback() | ||||
return err | return err | ||||
} | } | ||||
return err | return err | ||||
} | } | ||||
mode := WRITABLE | |||||
if repo.IsMirror { | |||||
mode = READABLE | |||||
} | |||||
// New owner is organization. | // New owner is organization. | ||||
if newUser.IsOrganization() { | if newUser.IsOrganization() { | ||||
mode := WRITABLE | |||||
if repo.IsMirror { | |||||
mode = READABLE | |||||
} | |||||
access := &Access{ | access := &Access{ | ||||
RepoName: path.Join(newUser.LowerName, repo.LowerName), | RepoName: path.Join(newUser.LowerName, repo.LowerName), | ||||
Mode: mode, | Mode: mode, | ||||
sess.Rollback() | sess.Rollback() | ||||
return err | return err | ||||
} | } | ||||
} else { | |||||
access := &Access{ | |||||
RepoName: path.Join(newUser.LowerName, repo.LowerName), | |||||
UserName: newUser.LowerName, | |||||
Mode: mode, | |||||
} | |||||
if _, err = sess.Insert(access); err != nil { | |||||
sess.Rollback() | |||||
return err | |||||
} | |||||
} | } | ||||
// Change repository directory name. | // Change repository directory name. |
// and returns a icon class name. | // and returns a icon class name. | ||||
func ActionIcon(opType int) string { | func ActionIcon(opType int) string { | ||||
switch opType { | switch opType { | ||||
case 1: // Create repository. | |||||
case 1, 8: // Create, transfer repository. | |||||
return "repo" | return "repo" | ||||
case 5, 9: // Commit repository. | case 5, 9: // Commit repository. | ||||
return "git-commit" | return "git-commit" | ||||
case 6: // Create issue. | case 6: // Create issue. | ||||
return "issue-opened" | return "issue-opened" | ||||
case 8: // Transfer repository. | |||||
return "share" | |||||
case 10: // Comment issue. | case 10: // Comment issue. | ||||
return "comment" | return "comment" | ||||
default: | default: | ||||
} | } | ||||
} | } | ||||
// TODO: Legacy | |||||
// FIXME: Legacy | |||||
const ( | const ( | ||||
TPL_CREATE_REPO = `<a href="%s/user/%s">%s</a> created repository <a href="%s">%s</a>` | TPL_CREATE_REPO = `<a href="%s/user/%s">%s</a> created repository <a href="%s">%s</a>` | ||||
TPL_COMMIT_REPO = `<a href="%s/user/%s">%s</a> pushed to <a href="%s/src/%s">%s</a> at <a href="%s">%s</a>%s` | TPL_COMMIT_REPO = `<a href="%s/user/%s">%s</a> pushed to <a href="%s/src/%s">%s</a> at <a href="%s">%s</a>%s` | ||||
return push | return push | ||||
} | } | ||||
// TODO: Legacy | |||||
// FIXME: Legacy | |||||
// ActionDesc accepts int that represents action operation type | // ActionDesc accepts int that represents action operation type | ||||
// and returns the description. | // and returns the description. | ||||
func ActionDesc(act Actioner) string { | func ActionDesc(act Actioner) string { |
0.5.4.0924 Beta | |||||
0.5.4.0925 Beta |
{{else if eq .GetOpType 6}} | {{else if eq .GetOpType 6}} | ||||
{{ $index := index .GetIssueInfos 0}} | {{ $index := index .GetIssueInfos 0}} | ||||
{{$.i18n.Tr "action.create_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} | {{$.i18n.Tr "action.create_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} | ||||
{{else if eq .GetOpType 8}} | |||||
{{$.i18n.Tr "action.transfer_repo" .GetRepoName AppSubUrl .GetRepoLink .GetRepoLink | Str2html}} | |||||
{{else if eq .GetOpType 10}} | {{else if eq .GetOpType 10}} | ||||
{{ $index := index .GetIssueInfos 0}} | {{ $index := index .GetIssueInfos 0}} | ||||
{{$.i18n.Tr "action.comment_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} | {{$.i18n.Tr "action.comment_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} |