Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance pipeline message and pr title #3421

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9b85108
Update pipeline list UI
anbraten Jan 30, 2024
79df566
Merge remote-tracking branch 'upstream/main' into update-pipeline-list
anbraten Feb 10, 2024
9bfd2f3
gitea parse email too
6543 Feb 21, 2024
d07b161
example how tests should be
6543 Feb 21, 2024
fb627db
fix similar bugs
6543 Feb 22, 2024
0cf1fb6
tests tests tests
6543 Feb 22, 2024
9a9231b
Merge branch 'main' into gitea-parse-mail-too
6543 Feb 22, 2024
55441bf
move old tests to new tests
6543 Feb 22, 2024
2b4e136
tags dont have branch info
6543 Feb 22, 2024
7165ef5
extend tests and finish migration
6543 Feb 22, 2024
c691b31
fix
6543 Feb 22, 2024
7db9650
actually differ between title and message and use it propperly
6543 Feb 22, 2024
d1f49c0
refactor
6543 Feb 22, 2024
7f23b07
update tests etc...
6543 Feb 22, 2024
f25b7b0
fix test
6543 Feb 22, 2024
ada1819
dont forget the gitlab
6543 Feb 22, 2024
3812c62
bitbucket
6543 Feb 22, 2024
b0d5168
Merge branch 'main' into actually-use-title
6543 Feb 22, 2024
114ba6a
Merge branch 'main' into actually-use-title
6543 Feb 22, 2024
59086fe
Merge branch 'main' into actually-use-title
6543 Feb 23, 2024
9df94d8
Merge branch 'main' into actually-use-title2
6543 Jun 3, 2024
7344a90
Merge remote-tracking branch 'upstream/main' into update-pipeline-list
anbraten Jun 24, 2024
36cf5af
adjust pipeline item
anbraten Jun 25, 2024
a0960bb
Merge branch 'update-pipeline-list' into pr/6543/3421-1
anbraten Jun 25, 2024
f89f4e8
Merge branch 'main' into actually-use-title
anbraten Jun 25, 2024
ba83f48
Merge branch 'main' into actually-use-title
6543 Jun 26, 2024
acc52fc
Merge remote-tracking branch 'upstream/main' into pr/6543/3421
anbraten Jul 2, 2024
756f9ea
Merge branch 'actually-use-title' of github.com:6543-forks/woodpecker…
anbraten Jul 2, 2024
39d5350
adjust pipeline message and title
anbraten Jul 2, 2024
87946fa
adjust ui text
anbraten Jul 2, 2024
651663c
adjust to proper values
anbraten Jul 2, 2024
fbc586e
Merge branch 'main' into actually-use-title
6543 Jul 2, 2024
020aa18
Merge remote-tracking branch 'upstream/main' into pr/6543/3421
anbraten Jul 13, 2024
6c12da1
Merge branch 'actually-use-title' of github.com:6543-forks/woodpecker…
anbraten Jul 13, 2024
168b1eb
Merge remote-tracking branch 'upstream/main' into pr/6543/3421
anbraten Jul 13, 2024
5f9c57c
Merge branch 'main' into actually-use-title
qwerty287 Jul 15, 2024
c6a8677
Merge branch 'main' into actually-use-title
6543 Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.buildTags": "test",
"gopls": {
// cspell:words gopls
"buildFlags": ["-tags=test"]
},
"eslint.workingDirectories": ["./web"],
"prettier.ignorePath": "./web/.prettierignore",
// Auto fix
Expand Down
2 changes: 1 addition & 1 deletion server/api/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func createTmpPipeline(event model.WebhookEvent, commit *model.Commit, user *mod
Timestamp: time.Now().UTC().Unix(),

Avatar: user.Avatar,
Message: "MANUAL PIPELINE @ " + opts.Branch,
Message: "manual pipeline @" + opts.Branch,

Ref: opts.Branch,
AdditionalVariables: opts.Variables,
Expand Down
15 changes: 8 additions & 7 deletions server/forge/bitbucket/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline {
from.PullRequest.Source.Branch.Name,
from.PullRequest.Dest.Branch.Name,
),
ForgeURL: from.PullRequest.Links.HTML.Href,
Branch: from.PullRequest.Dest.Branch.Name,
Message: from.PullRequest.Desc,
Avatar: from.Actor.Links.Avatar.Href,
Author: from.Actor.Login,
Sender: from.Actor.Login,
Timestamp: from.PullRequest.Updated.UTC().Unix(),
ForgeURL: from.PullRequest.Links.HTML.Href,
Branch: from.PullRequest.Dest.Branch.Name,
PRTitleDescription: from.PullRequest.Title + "\n" + from.PullRequest.Desc,
Message: "", // TODO: get last commit message
Avatar: from.Actor.Links.Avatar.Href,
Author: from.Actor.Login,
Sender: from.Actor.Login,
Timestamp: from.PullRequest.Updated.UTC().Unix(),
}
}

Expand Down
31 changes: 19 additions & 12 deletions server/forge/bitbucketdatacenter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ func convertRepositoryPushEvent(ev *bb.RepositoryPushEvent, baseURL string) *mod
return nil
}

message := ""
if ev.ToCommit != nil {
message = ev.ToCommit.Message
} else if len(ev.Commits) > 0 {
message = ev.Commits[0].Message
}

pipeline := &model.Pipeline{
Commit: change.ToHash,
Branch: change.Ref.DisplayID,
Message: "",
Message: message,
Avatar: bitbucketAvatarURL(baseURL, ev.Actor.Slug),
Author: authorLabel(ev.Actor.Name),
Email: ev.Actor.Email,
Expand All @@ -112,17 +119,17 @@ func convertRepositoryPushEvent(ev *bb.RepositoryPushEvent, baseURL string) *mod

func convertPullRequestEvent(ev *bb.PullRequestEvent, baseURL string) *model.Pipeline {
pipeline := &model.Pipeline{
Commit: ev.PullRequest.Source.Latest,
Branch: ev.PullRequest.Source.DisplayID,
Title: ev.PullRequest.Title,
Message: "",
Avatar: bitbucketAvatarURL(baseURL, ev.Actor.Slug),
Author: authorLabel(ev.Actor.Name),
Email: ev.Actor.Email,
Timestamp: time.Time(ev.Date).UTC().Unix(),
Ref: fmt.Sprintf("refs/pull-requests/%d/from", ev.PullRequest.ID),
ForgeURL: fmt.Sprintf("%s/projects/%s/repos/%s/commits/%s", baseURL, ev.PullRequest.Source.Repository.Project.Key, ev.PullRequest.Source.Repository.Slug, ev.PullRequest.Source.Latest),
Refspec: fmt.Sprintf("%s:%s", ev.PullRequest.Source.DisplayID, ev.PullRequest.Target.DisplayID),
Commit: ev.PullRequest.Source.Latest,
Branch: ev.PullRequest.Source.DisplayID,
PRTitleDescription: ev.PullRequest.Title,
Message: "", // TODO: get message from last commit to pr
Avatar: bitbucketAvatarURL(baseURL, ev.Actor.Slug),
Author: authorLabel(ev.Actor.Name),
Email: ev.Actor.Email,
Timestamp: time.Time(ev.Date).UTC().Unix(),
Ref: fmt.Sprintf("refs/pull-requests/%d/from", ev.PullRequest.ID),
ForgeURL: fmt.Sprintf("%s/projects/%s/repos/%s/commits/%s", baseURL, ev.PullRequest.Source.Repository.Project.Key, ev.PullRequest.Source.Repository.Slug, ev.PullRequest.Source.Latest),
Refspec: fmt.Sprintf("%s:%s", ev.PullRequest.Source.DisplayID, ev.PullRequest.Target.DisplayID),
}

if ev.EventKey == bb.EventKeyPullRequestMerged || ev.EventKey == bb.EventKeyPullRequestDeclined || ev.EventKey == bb.EventKeyPullRequestDeleted {
Expand Down
35 changes: 22 additions & 13 deletions server/forge/forgejo/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,21 @@ func pipelineFromTag(hook *pushHook) *model.Pipeline {
)
ref := strings.TrimPrefix(hook.Ref, "refs/tags/")

var message string
if len(hook.Commits) > 0 {
message = hook.Commits[0].Message
if len(hook.Commits) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty if

}
} else {
message = hook.HeadCommit.Message
}

return &model.Pipeline{
Event: model.EventTag,
Commit: hook.Sha,
Ref: fmt.Sprintf("refs/tags/%s", ref),
ForgeURL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, ref),
Message: fmt.Sprintf("created tag %s", ref),
Message: message,
Avatar: avatar,
Author: hook.Sender.UserName,
Sender: hook.Sender.UserName,
Expand All @@ -155,17 +164,17 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline {
}

pipeline := &model.Pipeline{
Event: event,
Commit: hook.PullRequest.Head.Sha,
ForgeURL: hook.PullRequest.HTMLURL,
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
Branch: hook.PullRequest.Base.Ref,
Message: hook.PullRequest.Title,
Author: hook.PullRequest.Poster.UserName,
Avatar: avatar,
Sender: hook.Sender.UserName,
Email: hook.Sender.Email,
Title: hook.PullRequest.Title,
Event: event,
Commit: hook.PullRequest.Head.Sha,
ForgeURL: hook.PullRequest.HTMLURL,
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
Branch: hook.PullRequest.Base.Ref,
Author: hook.PullRequest.Poster.UserName,
Avatar: avatar,
Sender: hook.Sender.UserName,
Email: hook.Sender.Email,
PRTitleDescription: hook.PullRequest.Title + "\n" + hook.PullRequest.Body,
Message: "", // TODO: get message from last commit to pr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does someone know if we can this data from the webhook somehow, or do we need to query the api again?

Refspec: fmt.Sprintf("%s:%s",
hook.PullRequest.Head.Ref,
hook.PullRequest.Base.Ref,
Expand All @@ -187,7 +196,7 @@ func pipelineFromRelease(hook *releaseHook) *model.Pipeline {
Ref: fmt.Sprintf("refs/tags/%s", hook.Release.TagName),
ForgeURL: hook.Release.HTMLURL,
Branch: hook.Release.Target,
Message: fmt.Sprintf("created release %s", hook.Release.Title),
Message: hook.Release.Title + "\n" + hook.Release.Note,
Avatar: avatar,
Author: hook.Sender.UserName,
Sender: hook.Sender.UserName,
Expand Down
102 changes: 51 additions & 51 deletions server/forge/forgejo/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ func TestForgejoParser(t *testing.T) {
},
},
pipe: &model.Pipeline{
Author: "gordon",
Event: "pull_request",
Commit: "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "feature/changes:main",
Title: "Update the README with new information",
Message: "Update the README with new information",
Sender: "gordon",
Avatar: "http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87",
Email: "[email protected]",
ForgeURL: "http://forgejo.golang.org/gordon/hello-world/pull/1",
PullRequestLabels: []string{},
Author: "gordon",
Event: "pull_request",
Commit: "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "feature/changes:main",
PRTitleDescription: "Update the README with new information",
Message: "Update the README with new information",
Sender: "gordon",
Avatar: "http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87",
Email: "[email protected]",
ForgeURL: "http://forgejo.golang.org/gordon/hello-world/pull/1",
PullRequestLabels: []string{},
},
},
{
Expand All @@ -243,18 +243,18 @@ func TestForgejoParser(t *testing.T) {
},
},
pipe: &model.Pipeline{
Author: "test",
Event: "pull_request",
Commit: "788ed8d02d3b7fcfcf6386dbcbca696aa1d4dc25",
Branch: "main",
Ref: "refs/pull/2/head",
Refspec: "test-patch-1:main",
Title: "New Pull",
Message: "New Pull",
Sender: "test",
Avatar: "http://127.0.0.1:3000/avatars/dd46a756faad4727fb679320751f6dea",
Email: "[email protected]",
ForgeURL: "http://127.0.0.1:3000/Test-CI/multi-line-secrets/pulls/2",
Author: "test",
Event: "pull_request",
Commit: "788ed8d02d3b7fcfcf6386dbcbca696aa1d4dc25",
Branch: "main",
Ref: "refs/pull/2/head",
Refspec: "test-patch-1:main",
PRTitleDescription: "New Pull",
Message: "New Pull",
Sender: "test",
Avatar: "http://127.0.0.1:3000/avatars/dd46a756faad4727fb679320751f6dea",
Email: "[email protected]",
ForgeURL: "http://127.0.0.1:3000/Test-CI/multi-line-secrets/pulls/2",
PullRequestLabels: []string{
"Kind/Bug",
"Kind/Security",
Expand Down Expand Up @@ -284,19 +284,19 @@ func TestForgejoParser(t *testing.T) {
},
},
pipe: &model.Pipeline{
Author: "anbraten",
Event: "pull_request_closed",
Commit: "d555a5dd07f4d0148a58d4686ec381502ae6a2d4",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "anbraten-patch-1:main",
Title: "Adjust file",
Message: "Adjust file",
Sender: "anbraten",
Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon",
Email: "[email protected]",
ForgeURL: "https://forgejo.com/anbraten/test-repo/pulls/1",
PullRequestLabels: []string{},
Author: "anbraten",
Event: "pull_request_closed",
Commit: "d555a5dd07f4d0148a58d4686ec381502ae6a2d4",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "anbraten-patch-1:main",
PRTitleDescription: "Adjust file",
Message: "Adjust file",
Sender: "anbraten",
Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon",
Email: "[email protected]",
ForgeURL: "https://forgejo.com/anbraten/test-repo/pulls/1",
PullRequestLabels: []string{},
},
},
{
Expand All @@ -322,19 +322,19 @@ func TestForgejoParser(t *testing.T) {
},
},
pipe: &model.Pipeline{
Author: "anbraten",
Event: "pull_request_closed",
Commit: "d555a5dd07f4d0148a58d4686ec381502ae6a2d4",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "anbraten-patch-1:main",
Title: "Adjust file",
Message: "Adjust file",
Sender: "anbraten",
Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon",
Email: "[email protected]",
ForgeURL: "https://forgejo.com/anbraten/test-repo/pulls/1",
PullRequestLabels: []string{},
Author: "anbraten",
Event: "pull_request_closed",
Commit: "d555a5dd07f4d0148a58d4686ec381502ae6a2d4",
Branch: "main",
Ref: "refs/pull/1/head",
Refspec: "anbraten-patch-1:main",
PRTitleDescription: "Adjust file",
Message: "Adjust file",
Sender: "anbraten",
Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon",
Email: "[email protected]",
ForgeURL: "https://forgejo.com/anbraten/test-repo/pulls/1",
PullRequestLabels: []string{},
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion server/forge/gitea/fixtures/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ const HookRelease = `
"tag_name": "0.0.5",
"target_commitish": "main",
"name": "Version 0.0.5",
"body": "",
"body": "release notes",
"url": "https://git.xxx/api/v1/repos/anbraten/demo/releases/48",
"html_url": "https://git.xxx/anbraten/demo/releases/tag/0.0.5",
"tarball_url": "https://git.xxx/anbraten/demo/archive/0.0.5.tar.gz",
Expand Down
Loading