mirror of
https://github.com/gogs/gogs.git
synced 2025-05-24 16:30:51 +00:00
dashboard: add delete branch and tag news feeds
This commit is contained in:
parent
f0086e66ae
commit
70072e2842
@ -1210,17 +1210,20 @@ notices.delete_success = System notices have been deleted successfully.
|
|||||||
create_repo = created repository <a href="%s">%s</a>
|
create_repo = created repository <a href="%s">%s</a>
|
||||||
rename_repo = renamed repository from <code>%[1]s</code> to <a href="%[2]s">%[3]s</a>
|
rename_repo = renamed repository from <code>%[1]s</code> to <a href="%[2]s">%[3]s</a>
|
||||||
commit_repo = pushed to <a href="%[1]s/src/%[2]s">%[3]s</a> at <a href="%[1]s">%[4]s</a>
|
commit_repo = pushed to <a href="%[1]s/src/%[2]s">%[3]s</a> at <a href="%[1]s">%[4]s</a>
|
||||||
|
compare_commits = View comparison for these %d commits
|
||||||
|
transfer_repo = transfered repository <code>%s</code> to <a href="%s">%s</a>
|
||||||
create_issue = `opened issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
create_issue = `opened issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
||||||
close_issue = `closed issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
close_issue = `closed issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
||||||
reopen_issue = `reopened issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
reopen_issue = `reopened issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
||||||
|
comment_issue = `commented on issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
||||||
create_pull_request = `created pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
create_pull_request = `created pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
close_pull_request = `closed pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
close_pull_request = `closed pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
reopen_pull_request = `reopened pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
reopen_pull_request = `reopened pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
comment_issue = `commented on issue <a href="%s/issues/%s">%s#%[2]s</a>`
|
|
||||||
merge_pull_request = `merged pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
merge_pull_request = `merged pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
transfer_repo = transfered repository <code>%s</code> to <a href="%s">%s</a>
|
create_branch = created new branch <a href="%[1]s/src/%[2]s">%[3]s</a> at <a href="%[1]s">%[4]s</a>
|
||||||
|
delete_branch = deleted branch <code>%[2]s</code> at <a href="%[1]s">%[3]s</a>
|
||||||
push_tag = pushed tag <a href="%s/src/%s">%[2]s</a> to <a href="%[1]s">%[3]s</a>
|
push_tag = pushed tag <a href="%s/src/%s">%[2]s</a> to <a href="%[1]s">%[3]s</a>
|
||||||
compare_commits = View comparison for these %d commits
|
delete_tag = deleted tag <code>%[2]s</code> at <a href="%[1]s">%[3]s</a>
|
||||||
|
|
||||||
[tool]
|
[tool]
|
||||||
ago = ago
|
ago = ago
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
type ActionType int
|
type ActionType int
|
||||||
|
|
||||||
|
// To maintain backward compatibility only append to the end of list
|
||||||
const (
|
const (
|
||||||
ACTION_CREATE_REPO ActionType = iota + 1 // 1
|
ACTION_CREATE_REPO ActionType = iota + 1 // 1
|
||||||
ACTION_RENAME_REPO // 2
|
ACTION_RENAME_REPO // 2
|
||||||
@ -42,6 +43,9 @@ const (
|
|||||||
ACTION_REOPEN_ISSUE // 13
|
ACTION_REOPEN_ISSUE // 13
|
||||||
ACTION_CLOSE_PULL_REQUEST // 14
|
ACTION_CLOSE_PULL_REQUEST // 14
|
||||||
ACTION_REOPEN_PULL_REQUEST // 15
|
ACTION_REOPEN_PULL_REQUEST // 15
|
||||||
|
ACTION_CREATE_BRANCH // 16
|
||||||
|
ACTION_DELETE_BRANCH // 17
|
||||||
|
ACTION_DELETE_TAG // 18
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -66,7 +70,7 @@ func init() {
|
|||||||
// Action represents user operation type and other information to repository,
|
// Action represents user operation type and other information to repository,
|
||||||
// it implemented interface base.Actioner so that can be used in template render.
|
// it implemented interface base.Actioner so that can be used in template render.
|
||||||
type Action struct {
|
type Action struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64
|
||||||
UserID int64 // Receiver user id.
|
UserID int64 // Receiver user id.
|
||||||
OpType ActionType
|
OpType ActionType
|
||||||
ActUserID int64 // Action user id.
|
ActUserID int64 // Action user id.
|
||||||
@ -485,30 +489,32 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
return fmt.Errorf("Marshal: %v", err)
|
return fmt.Errorf("Marshal: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
// It's safe to fail when the whole function is called during hook execution
|
||||||
|
// because resource released after exit.
|
||||||
|
go HookQueue.Add(repo.ID)
|
||||||
|
}()
|
||||||
|
|
||||||
refName := git.RefEndName(opts.RefFullName)
|
refName := git.RefEndName(opts.RefFullName)
|
||||||
if err = NotifyWatchers(&Action{
|
action := &Action{
|
||||||
ActUserID: pusher.ID,
|
ActUserID: pusher.ID,
|
||||||
ActUserName: pusher.Name,
|
ActUserName: pusher.Name,
|
||||||
OpType: opType,
|
|
||||||
Content: string(data),
|
Content: string(data),
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
RepoUserName: repo.MustOwner().Name,
|
RepoUserName: repo.MustOwner().Name,
|
||||||
RepoName: repo.Name,
|
RepoName: repo.Name,
|
||||||
RefName: refName,
|
RefName: refName,
|
||||||
IsPrivate: repo.IsPrivate,
|
IsPrivate: repo.IsPrivate,
|
||||||
}); err != nil {
|
|
||||||
return fmt.Errorf("NotifyWatchers: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
|
||||||
go HookQueue.Add(repo.ID)
|
|
||||||
}()
|
|
||||||
|
|
||||||
apiRepo := repo.APIFormat(nil)
|
apiRepo := repo.APIFormat(nil)
|
||||||
apiPusher := pusher.APIFormat()
|
apiPusher := pusher.APIFormat()
|
||||||
switch opType {
|
switch opType {
|
||||||
case ACTION_COMMIT_REPO: // Push
|
case ACTION_COMMIT_REPO: // Push
|
||||||
if isDelRef {
|
if isDelRef {
|
||||||
|
action.OpType = ACTION_DELETE_BRANCH
|
||||||
|
MustNotifyWatchers(action)
|
||||||
|
|
||||||
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
RefType: "branch",
|
RefType: "branch",
|
||||||
@ -525,6 +531,9 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
|
|
||||||
compareURL := setting.AppUrl + opts.Commits.CompareURL
|
compareURL := setting.AppUrl + opts.Commits.CompareURL
|
||||||
if isNewRef {
|
if isNewRef {
|
||||||
|
action.OpType = ACTION_CREATE_BRANCH
|
||||||
|
MustNotifyWatchers(action)
|
||||||
|
|
||||||
compareURL = ""
|
compareURL = ""
|
||||||
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
|
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
@ -537,6 +546,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action.OpType = ACTION_COMMIT_REPO
|
||||||
|
MustNotifyWatchers(action)
|
||||||
if err = PrepareWebhooks(repo, HOOK_EVENT_PUSH, &api.PushPayload{
|
if err = PrepareWebhooks(repo, HOOK_EVENT_PUSH, &api.PushPayload{
|
||||||
Ref: opts.RefFullName,
|
Ref: opts.RefFullName,
|
||||||
Before: opts.OldCommitID,
|
Before: opts.OldCommitID,
|
||||||
@ -552,6 +563,9 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
|
|
||||||
case ACTION_PUSH_TAG: // Tag
|
case ACTION_PUSH_TAG: // Tag
|
||||||
if isDelRef {
|
if isDelRef {
|
||||||
|
action.OpType = ACTION_DELETE_TAG
|
||||||
|
MustNotifyWatchers(action)
|
||||||
|
|
||||||
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
RefType: "tag",
|
RefType: "tag",
|
||||||
@ -564,6 +578,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action.OpType = ACTION_PUSH_TAG
|
||||||
|
MustNotifyWatchers(action)
|
||||||
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
|
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
RefType: "tag",
|
RefType: "tag",
|
||||||
|
@ -2075,7 +2075,7 @@ func notifyWatchers(e Engine, act *Action) error {
|
|||||||
|
|
||||||
// Add feed for actioner.
|
// Add feed for actioner.
|
||||||
act.UserID = act.ActUserID
|
act.UserID = act.ActUserID
|
||||||
if _, err = e.InsertOne(act); err != nil {
|
if _, err = e.Insert(act); err != nil {
|
||||||
return fmt.Errorf("insert new actioner: %v", err)
|
return fmt.Errorf("insert new actioner: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2086,7 +2086,7 @@ func notifyWatchers(e Engine, act *Action) error {
|
|||||||
|
|
||||||
act.ID = 0
|
act.ID = 0
|
||||||
act.UserID = watches[i].UserID
|
act.UserID = watches[i].UserID
|
||||||
if _, err = e.InsertOne(act); err != nil {
|
if _, err = e.Insert(act); err != nil {
|
||||||
return fmt.Errorf("insert new action: %v", err)
|
return fmt.Errorf("insert new action: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2098,6 +2098,13 @@ func NotifyWatchers(act *Action) error {
|
|||||||
return notifyWatchers(x, act)
|
return notifyWatchers(x, act)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MustNotifyWatchers(act *Action) {
|
||||||
|
act.ID = 0 // Reset ID to reuse Action object
|
||||||
|
if err := NotifyWatchers(act); err != nil {
|
||||||
|
log.Error(2, "NotifyWatchers: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// _________ __
|
// _________ __
|
||||||
// / _____// |______ _______
|
// / _____// |______ _______
|
||||||
// \_____ \\ __\__ \\_ __ \
|
// \_____ \\ __\__ \\_ __ \
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2921,7 +2921,7 @@ footer .ui.language .menu {
|
|||||||
font-family: Consolas, monospace;
|
font-family: Consolas, monospace;
|
||||||
}
|
}
|
||||||
.feeds .news code {
|
.feeds .news code {
|
||||||
padding: 1px;
|
padding: 3px;
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
background-color: rgba(0, 0, 0, 0.04);
|
background-color: rgba(0, 0, 0, 0.04);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
font-family: Consolas, monospace;
|
font-family: Consolas, monospace;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
padding: 1px;
|
padding: 3px;
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
background-color: rgba(0, 0, 0, 0.04);
|
background-color: rgba(0, 0, 0, 0.04);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<div class="{{if eq .GetOpType 5}}push news{{end}}">
|
<div class="{{if eq .GetOpType 5}}push news{{end}}">
|
||||||
<p>
|
<p>
|
||||||
<a href="{{AppSubUrl}}/{{.GetActUserName}}">{{.ShortActUserName}}</a>
|
<a href="{{AppSubUrl}}/{{.GetActUserName}}">{{.ShortActUserName}}</a>
|
||||||
|
<!-- Reference types to models/action.go -->
|
||||||
{{if eq .GetOpType 1}}
|
{{if eq .GetOpType 1}}
|
||||||
{{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoPath | Str2html}}
|
{{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoPath | Str2html}}
|
||||||
{{else if eq .GetOpType 2}}
|
{{else if eq .GetOpType 2}}
|
||||||
@ -43,6 +44,13 @@
|
|||||||
{{else if eq .GetOpType 15}}
|
{{else if eq .GetOpType 15}}
|
||||||
{{ $index := index .GetIssueInfos 0}}
|
{{ $index := index .GetIssueInfos 0}}
|
||||||
{{$.i18n.Tr "action.reopen_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}}
|
{{$.i18n.Tr "action.reopen_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}}
|
||||||
|
{{else if eq .GetOpType 16}}
|
||||||
|
{{ $branchLink := .GetBranch | EscapePound}}
|
||||||
|
{{$.i18n.Tr "action.create_branch" .GetRepoLink $branchLink .GetBranch .ShortRepoPath | Str2html}}
|
||||||
|
{{else if eq .GetOpType 17}}
|
||||||
|
{{$.i18n.Tr "action.delete_branch" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
||||||
|
{{else if eq .GetOpType 18}}
|
||||||
|
{{$.i18n.Tr "action.delete_tag" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</p>
|
</p>
|
||||||
{{if eq .GetOpType 5}}
|
{{if eq .GetOpType 5}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user