![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) | ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) | ||||
##### Current version: 0.8.41 | |||||
##### Current version: 0.8.42 | |||||
| Web | UI | Preview | | | Web | UI | Preview | | ||||
|:-------------:|:-------:|:-------:| | |:-------------:|:-------:|:-------:| |
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"}, | {"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"}, | ||||
{"gopkg.in/ini.v1", ini.Version, "1.8.4"}, | {"gopkg.in/ini.v1", ini.Version, "1.8.4"}, | ||||
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"}, | {"gopkg.in/macaron.v1", macaron.Version, "0.8.0"}, | ||||
{"github.com/gogits/git-module", git.Version, "0.2.5"}, | |||||
{"github.com/gogits/git-module", git.Version, "0.2.6"}, | |||||
{"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"}, | {"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"}, | ||||
} | } | ||||
for _, c := range checkers { | for _, c := range checkers { |
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> | ||||
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>` | |||||
reopen_issue = `reopened 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>` | ||||
comment_issue = `commented on issue <a href="%s/issues/%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>` |
"github.com/gogits/gogs/modules/setting" | "github.com/gogits/gogs/modules/setting" | ||||
) | ) | ||||
const APP_VER = "0.8.41.0221" | |||||
const APP_VER = "0.8.42.0222" | |||||
func init() { | func init() { | ||||
runtime.GOMAXPROCS(runtime.NumCPU()) | runtime.GOMAXPROCS(runtime.NumCPU()) |
type ActionType int | type ActionType int | ||||
const ( | const ( | ||||
CREATE_REPO ActionType = iota + 1 // 1 | |||||
RENAME_REPO // 2 | |||||
STAR_REPO // 3 | |||||
FOLLOW_REPO // 4 | |||||
COMMIT_REPO // 5 | |||||
CREATE_ISSUE // 6 | |||||
CREATE_PULL_REQUEST // 7 | |||||
TRANSFER_REPO // 8 | |||||
PUSH_TAG // 9 | |||||
COMMENT_ISSUE // 10 | |||||
MERGE_PULL_REQUEST // 11 | |||||
ACTION_CREATE_REPO ActionType = iota + 1 // 1 | |||||
ACTION_RENAME_REPO // 2 | |||||
ACTION_STAR_REPO // 3 | |||||
ACTION_WATCH_REPO // 4 | |||||
ACTION_COMMIT_REPO // 5 | |||||
ACTION_CREATE_ISSUE // 6 | |||||
ACTION_CREATE_PULL_REQUEST // 7 | |||||
ACTION_TRANSFER_REPO // 8 | |||||
ACTION_PUSH_TAG // 9 | |||||
ACTION_COMMENT_ISSUE // 10 | |||||
ACTION_MERGE_PULL_REQUEST // 11 | |||||
ACTION_CLOSE_ISSUE // 12 | |||||
ACTION_REOPEN_ISSUE // 13 | |||||
) | ) | ||||
var ( | var ( | ||||
ActUserID: u.Id, | ActUserID: u.Id, | ||||
ActUserName: u.Name, | ActUserName: u.Name, | ||||
ActEmail: u.Email, | ActEmail: u.Email, | ||||
OpType: CREATE_REPO, | |||||
OpType: ACTION_CREATE_REPO, | |||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: repo.Owner.Name, | RepoUserName: repo.Owner.Name, | ||||
RepoName: repo.Name, | RepoName: repo.Name, | ||||
ActUserID: actUser.Id, | ActUserID: actUser.Id, | ||||
ActUserName: actUser.Name, | ActUserName: actUser.Name, | ||||
ActEmail: actUser.Email, | ActEmail: actUser.Email, | ||||
OpType: RENAME_REPO, | |||||
OpType: ACTION_RENAME_REPO, | |||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: repo.Owner.Name, | RepoUserName: repo.Owner.Name, | ||||
RepoName: repo.Name, | RepoName: repo.Name, | ||||
} | } | ||||
isNewBranch := false | isNewBranch := false | ||||
opType := COMMIT_REPO | |||||
opType := ACTION_COMMIT_REPO | |||||
// Check it's tag push or branch. | // Check it's tag push or branch. | ||||
if strings.HasPrefix(refFullName, "refs/tags/") { | if strings.HasPrefix(refFullName, "refs/tags/") { | ||||
opType = PUSH_TAG | |||||
opType = ACTION_PUSH_TAG | |||||
commit = &PushCommits{} | commit = &PushCommits{} | ||||
} else { | } else { | ||||
// if not the first commit, set the compareUrl | // if not the first commit, set the compareUrl | ||||
} | } | ||||
switch opType { | switch opType { | ||||
case COMMIT_REPO: // Push | |||||
case ACTION_COMMIT_REPO: // Push | |||||
p := &api.PushPayload{ | p := &api.PushPayload{ | ||||
Ref: refFullName, | Ref: refFullName, | ||||
Before: oldCommitID, | Before: oldCommitID, | ||||
}) | }) | ||||
} | } | ||||
case PUSH_TAG: // Create | |||||
case ACTION_PUSH_TAG: // Create | |||||
return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{ | return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{ | ||||
Ref: refName, | Ref: refName, | ||||
RefType: "tag", | RefType: "tag", | ||||
ActUserID: actUser.Id, | ActUserID: actUser.Id, | ||||
ActUserName: actUser.Name, | ActUserName: actUser.Name, | ||||
ActEmail: actUser.Email, | ActEmail: actUser.Email, | ||||
OpType: TRANSFER_REPO, | |||||
OpType: ACTION_TRANSFER_REPO, | |||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: newOwner.Name, | RepoUserName: newOwner.Name, | ||||
RepoName: repo.Name, | RepoName: repo.Name, | ||||
ActUserID: actUser.Id, | ActUserID: actUser.Id, | ||||
ActUserName: actUser.Name, | ActUserName: actUser.Name, | ||||
ActEmail: actUser.Email, | ActEmail: actUser.Email, | ||||
OpType: MERGE_PULL_REQUEST, | |||||
OpType: ACTION_MERGE_PULL_REQUEST, | |||||
Content: fmt.Sprintf("%d|%s", pull.Index, pull.Name), | Content: fmt.Sprintf("%d|%s", pull.Index, pull.Name), | ||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: repo.Owner.Name, | RepoUserName: repo.Owner.Name, |
ActUserID: issue.Poster.Id, | ActUserID: issue.Poster.Id, | ||||
ActUserName: issue.Poster.Name, | ActUserName: issue.Poster.Name, | ||||
ActEmail: issue.Poster.Email, | ActEmail: issue.Poster.Email, | ||||
OpType: CREATE_ISSUE, | |||||
OpType: ACTION_CREATE_ISSUE, | |||||
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name), | Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name), | ||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: repo.Owner.Name, | RepoUserName: repo.Owner.Name, | ||||
return nil, err | return nil, err | ||||
} | } | ||||
// Compose comment action, could be plain comment, close or reopen issue. | |||||
// This object will be used to notify watchers in the end of function. | |||||
act := &Action{ | |||||
ActUserID: u.Id, | |||||
ActUserName: u.Name, | |||||
ActEmail: u.Email, | |||||
Content: fmt.Sprintf("%d|%s", issue.Index, strings.Split(content, "\n")[0]), | |||||
RepoID: repo.ID, | |||||
RepoUserName: repo.Owner.Name, | |||||
RepoName: repo.Name, | |||||
IsPrivate: repo.IsPrivate, | |||||
} | |||||
// Check comment type. | // Check comment type. | ||||
switch cmtType { | switch cmtType { | ||||
case COMMENT_TYPE_COMMENT: | case COMMENT_TYPE_COMMENT: | ||||
act.OpType = ACTION_COMMENT_ISSUE | |||||
if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", issue.ID); err != nil { | if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", issue.ID); err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Notify watchers. | |||||
act := &Action{ | |||||
ActUserID: u.Id, | |||||
ActUserName: u.Name, | |||||
ActEmail: u.Email, | |||||
OpType: COMMENT_ISSUE, | |||||
Content: fmt.Sprintf("%d|%s", issue.Index, strings.Split(content, "\n")[0]), | |||||
RepoID: repo.ID, | |||||
RepoUserName: repo.Owner.Name, | |||||
RepoName: repo.Name, | |||||
IsPrivate: repo.IsPrivate, | |||||
} | |||||
if err = notifyWatchers(e, act); err != nil { | |||||
return nil, err | |||||
} | |||||
case COMMENT_TYPE_REOPEN: | case COMMENT_TYPE_REOPEN: | ||||
act.OpType = ACTION_REOPEN_ISSUE | |||||
if issue.IsPull { | if issue.IsPull { | ||||
_, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls-1 WHERE id=?", repo.ID) | _, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls-1 WHERE id=?", repo.ID) | ||||
} else { | } else { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
case COMMENT_TYPE_CLOSE: | case COMMENT_TYPE_CLOSE: | ||||
act.OpType = ACTION_CLOSE_ISSUE | |||||
if issue.IsPull { | if issue.IsPull { | ||||
_, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls+1 WHERE id=?", repo.ID) | _, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls+1 WHERE id=?", repo.ID) | ||||
} else { | } else { | ||||
} | } | ||||
} | } | ||||
// Notify watchers for whatever action comes in. | |||||
if err = notifyWatchers(e, act); err != nil { | |||||
return nil, fmt.Errorf("notifyWatchers: %v", err) | |||||
} | |||||
return comment, nil | return comment, nil | ||||
} | } | ||||
ActUserID: pull.Poster.Id, | ActUserID: pull.Poster.Id, | ||||
ActUserName: pull.Poster.Name, | ActUserName: pull.Poster.Name, | ||||
ActEmail: pull.Poster.Email, | ActEmail: pull.Poster.Email, | ||||
OpType: CREATE_PULL_REQUEST, | |||||
OpType: ACTION_CREATE_PULL_REQUEST, | |||||
Content: fmt.Sprintf("%d|%s", pull.Index, pull.Name), | Content: fmt.Sprintf("%d|%s", pull.Index, pull.Name), | ||||
RepoID: repo.ID, | RepoID: repo.ID, | ||||
RepoUserName: repo.Owner.Name, | RepoUserName: repo.Owner.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, 8: // Create, transfer repository | |||||
case 1, 8: // Create and 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, 13: // Create and reopen issue | |||||
return "issue-opened" | return "issue-opened" | ||||
case 7: // New pull request | case 7: // New pull request | ||||
return "git-pull-request" | return "git-pull-request" | ||||
return "comment" | return "comment" | ||||
case 11: // Merge pull request | case 11: // Merge pull request | ||||
return "git-merge" | return "git-merge" | ||||
case 12: // Close issue | |||||
return "issue-closed" | |||||
default: | default: | ||||
return "invalid type" | return "invalid type" | ||||
} | } |
if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil { | if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil { | ||||
log.Error(4, "ChangeStatus: %v", err) | log.Error(4, "ChangeStatus: %v", err) | ||||
} else { | } else { | ||||
log.Trace("Issue[%d] status changed to closed: %v", issue.ID, issue.IsClosed) | |||||
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed) | |||||
} | } | ||||
} | } | ||||
} | } |
0.8.41.0221 | |||||
0.8.42.0222 |
{{else if eq .GetOpType 11}} | {{else if eq .GetOpType 11}} | ||||
{{ $index := index .GetIssueInfos 0}} | {{ $index := index .GetIssueInfos 0}} | ||||
{{$.i18n.Tr "action.merge_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | {{$.i18n.Tr "action.merge_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | ||||
{{else if eq .GetOpType 12}} | |||||
{{ $index := index .GetIssueInfos 0}} | |||||
{{$.i18n.Tr "action.close_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||||
{{else if eq .GetOpType 13}} | |||||
{{ $index := index .GetIssueInfos 0}} | |||||
{{$.i18n.Tr "action.reopen_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||||
{{end}} | {{end}} | ||||
</p> | </p> | ||||
{{if eq .GetOpType 5}} | {{if eq .GetOpType 5}} | ||||
<p class="text light grey">{{index .GetIssueInfos 1}}</p> | <p class="text light grey">{{index .GetIssueInfos 1}}</p> | ||||
{{else if eq .GetOpType 11}} | {{else if eq .GetOpType 11}} | ||||
<p class="text light grey">{{index .GetIssueInfos 1}}</p> | <p class="text light grey">{{index .GetIssueInfos 1}}</p> | ||||
{{else if (or (eq .GetOpType 12) (eq .GetOpType 13))}} | |||||
<span class="text truncate issue title">{{.GetIssueTitle}}</span> | |||||
{{end}} | {{end}} | ||||
<p class="text italic light grey">{{TimeSince .GetCreate $.i18n.Lang}}</p> | <p class="text italic light grey">{{TimeSince .GetCreate $.i18n.Lang}}</p> | ||||
</div> | </div> |