[DEPRECATED] The Github Linkback Plugin

(Robin Ward) #1

:mega: :warning: This plugin is no longer supported, please migrate to GitHub - discourse/discourse-github :warning: :mega:

I’ve just released discourse-github-linkback which is a plugin designed to link github commits and pull requests back to forums where they’re mentioned.

Background: Often I’m looking at a commit on Github, and I’m not entirely sure why a change was made. We do most of our discussion on meta.discourse.org, so there is often a post or topic about the change with more context. Previously, I would search on meta for the commit or pull request, but that was difficult to do and cumbersome.

How the plugin works: If you link to a commit or pull request, for example this one, a background task will then post a link on the github content with a message that links to the post on meta where it was mentioned:

Now the connection works both ways! By browsing on Github you will find the link back to meta! This should make it a lot easier to find discussion and context for many changes in the Discourse codebase.

Salesforce integration in closed community?
Interact with discourse from Python?
How Does Team Discourse Use Discourse?
Pingbacks. They're all the rage
(Michael Downey) #2

I assume this doesn’t post a GH comment each & every mention correct? (i.e. max 1 per topic + PR/commit combo?)

(Robin Ward) #3

It’s restricted to one per post, as it could link to different posts in the same topic. I think it would be rare to keep linking the same PR in a topic though.

(Michael Downey) #4

Seems reasonable to start. Cool idea!

(Robby O'Connor) #5

I’m tempted to install this as a trial…

(Robin Ward) #6

We’ve been using it here with no trouble for the last few days.

(Erlend Sogge Heggen) #7

Seems two linkbacks were triggered here:

(Jeff Atwood) #8

Well yes, on two different topics? I don’t think there is a topic restriction, many topics could link to the same PR, but we can confirm with @eviltrout?

(Erlend Sogge Heggen) #9

No, scroll further up, there’s two from the same topic. I didn’t consider the fact that my post would also create a linkback!

(Robin Ward) #10

Yes the restriction right now is only by post, not by topic. The idea was: what if there is a long topic that links to the issue a second time? would you not want to know the context of both links?

1 Like
(Jeff Atwood) #11

Maybe, would be onerous if the topic linked back in 6 or 7 different posts, but we can ignore this for now is my vote.

(Erlend Sogge Heggen) #12

Where did these linkbacks come from?

(cpradio) #13

Looking at the edit history of

There used to be a PR related link, it was removed by codinghorror 2 days ago (revision 8-9).

(Dave McClure) #14

We had a similar kind of complaint about the Slack plugin when watching a tag. When there was a flurry of activity on a given topic, it got pretty noisy. So we turned it down to “following” in that case (watching first post).

But I think in my ideal world, there would be something in between, where it would notify the channel at most once per day (or some other time period) for a given topic.

Something similar could be done here if it becomes an issue.

(David Taylor) #15

In the discourse-slack-official plugin, there is a hard coded “don’t notify within 5 minutes”, but only if you’re using the “access token” method rather than the “webhook” method. I guess it was added for a specific Discourse customer at some point in the past.

Instead of sending a new message it just edits the existing message to add on the new notification. I would guess the github API has similar functionality for editing existing posts - so that kind of methodology could work here as well. (but for 1 day instead of 5 mins)

(Dave McClure) #16

I thought that was just about delaying the notification to allow for edits to the message on the Discourse side, not about rate limiting messages from a busy topic.

(David Taylor) #17

That feature does indeed exist, but is not what I’m talking about

This line is a hard coded “if time since last message about this topic is less than 5 mins, edit the last message”.

I also had no idea it existed until I started digging through the code recently - most people won’t even hit that codepath because it’s only for the “access token” method of posting.

It was added back in 2016

I’m planning to put it in as a customisable site setting in discourse-chat-integration, as it is quite a useful feature!

Also sorry, pulled this conversation slightly off topic :wink:


Forgive my not being able to read between the lines here, but I’m not sure how to configure the plugin after it’s installed.

Specifically, how does one configure the plugin to work with a repo that’s in an organization when the Personal access tokens are linked to a particular user? Also, what is the syntax to specify the github linkback projects? Is it just the repo name (i.e. myrepo), the owner/repo name (i.e. user1/myrepo), the rep url (i.e. https://www.github.com/user1/myrepo), or something else?


(Robin Ward) #19

The personal access token is from the account you want to post as. In our case we had a github user we’d already used for some notifications so I created a token for that.

The syntax for projects is user/repo – for example discourse/onebox

(Daniela) #20

I can not set this plugin to work. It looks like it won’t work at all, so I have no errors in logs. :disappointed_relieved:

I did not create our project on github, but I have the administrative rights for the repository I want to add to Discourse.
I generated the token to include on discourse from my github profile.

Are there any special permissions I have to check on Github?

I also wanted to point out that something does not work well here on Meta too.

I was on this topic https://meta.discourse.org/t/unable-to-change-themes-video-demo/70800/3 when @zogstrip responded by linking the fix to github.
And open that link I see that the automatic reply has been added more than once with repeated links to the same two topics.

BTW a soft refresh on the github page solve the issue.
If you don’t refresh the page new (duplicate) replies continue to appear every X minutes and be reported on the browser tab (at least on Firefox).

1 Like