Skip to content
Merged
Changes from 1 commit
Commits
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
20 changes: 20 additions & 0 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ func (p *Plugin) pipelineRunCommand(ctx context.Context, namespace, ref, channel
if err != nil {
return err.Error()
}

var txt string
if pipelineInfo == nil {
txt = "Currently there is no pipeline info"
Expand All @@ -738,6 +739,25 @@ func (p *Plugin) pipelineRunCommand(ctx context.Context, namespace, ref, channel
txt += fmt.Sprintf("**Ref**: %s\n", pipelineInfo.Ref)
txt += fmt.Sprintf("**Triggered By**: %s\n", pipelineInfo.User)
txt += fmt.Sprintf("**Visit pipeline [here](%s)** \n\n", pipelineInfo.WebURL)

foundPipelineSubscription := false
subs, err := p.GetSubscriptionsByChannel(channelID)
if err != nil {
p.API.LogWarn("Failed to get subscriptions for the channel", "ChannelID", channelID, "Error", err.Error())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0/5 we should use the pluginapi package when possible

Suggested change
p.API.LogWarn("Failed to get subscriptions for the channel", "ChannelID", channelID, "Error", err.Error())
p.client.Log.Warn("Failed to get subscriptions for the channel", "channel_id", channelID, "error", err.Error())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mickmister Updated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

0/5 we should use the pluginapi package when possible

@mickmister Are you referring to this https://pkg.go.dev/github.com/mattermost/mattermost-plugin-api package?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return txt
}

for _, sub := range subs {
if sub.Repository == namespace && sub.Pipeline() {
foundPipelineSubscription = true
break
}
}

if !foundPipelineSubscription {
txt += fmt.Sprintf("\n\n**Note:** This channel is currently not subscribed to pipeline event for `%s`. Run the command below if would you like to create a subscription.\n\n`/gitlab subscriptions add %s pipeline`", namespace, namespace)
}

return txt
}

Expand Down