Discourse GitHub

This plugin combines functionality of deprecated github_badges and discourse-github-linkback plugins.

Repository URL

https://github.com/discourse/discourse-github

Installation

Follow the plugin installation guide.

Github Badges

Assign badges to your users based on GitHub contributions.

How to use:

  1. Enable github badges enabled in Settings -> Plugins.
  2. Generate a GitHub access token and paste it into the github linkback access token setting. See below for instructions.
  3. Add one or more URLs of the GitHub repos to scan for contributions to the github badges repos site setting.

Github Linkback

Create a link from a Github pull request or commit back to a Discourse post where it is mentioned.

How to use:

  1. Enable github linkback enabled in Settings -> Plugins.
  2. Generate a GitHub access token and paste it into the github linkback access token setting. See below for instructions.
  3. Finally, add the projects you wish to post to in the github linkback projects site setting in the formats:
    • username/repository for specific repositories
    • username/* for all repositories of a certain user

Github Permalink

Replace Github non-permalinks with permalinks.

How to use:

  1. Enable github permalinks enabled in Settings -> Plugins.

GitHub Access Token

In order for the linkback feature to work and the badges to be granted to your users, you need to provide a Github access token. You can generate your token here: https://github.com/settings/tokens/new.

The linkback feature requires the public_repo scope, and granting badges requires no scope (leave everything unchecked if you only want badges). Since the public_repo scope grants write access to repositories, we recommend you create a new Github account and use it just to generate a token.

14 Likes

Hi, I hope this is the good place to ask for help:

  • Is there a way to troubleshoot the linkback? It worked well with previous plugin but am not anymore able to make it work. I recreated the access token in case…
  • I don’t understand how badges work…
1 Like

Yep, this is a fine place. I’ve asked my colleague @maja to assist when she’s back next week, she did the work combining the plugins.

I can confirm that linkback is still working for us here on Meta since we switched plugins, so I’m not sure what’s happening there.

4 Likes

Thanks Joshua,

I guessed indeed the plugin has been tested and validated, I’m uncomfortable not to be able to provide any further relevant information about my issue…

edit: in the settings, is the dropdown box labelled “List of projects to link back from” supposed to display filtered results when you start writing in it?

I’m not sure what’s causing problems since the new discourse-github plugin is reusing the old site settings and code didn’t change either. Did you manage to find anything meaningful in the logs? Is the old discourse-github-linkback still installed? Perhaps that’s interfering with the new plugin.

The dropdown for github linkback projects is used only for creating new entries, it doesn’t have any collection of options to filter from.

7 Likes

Thanks for reply @maja, it seems there is something I misunderstood in rights of categories in which there is a thread that should be linked back. Apparently the category needs to writeable by everyone or it doesn’t work, I’m not sure yet but it seems that my issue comes from the fact “everyone” can only “see” and not “Create / reply /see” (I need to make some tests to confirm)

edit: well, I don’t understand, it worked once after I set my testing category with rights “everyone” "can “create/reply/see” so I tried the same change in “production” category: it did not work. Furthermore, it stopped to work in my testing category just after. I can’t find anything related in logs page, but maybe there is another way to troubleshoot?

edit2: it seems really related to rights. Sorry for noise, please consider my issue as non-issue. However it may be interesting to know the way to easily troubleshoot this plugin, if there is :slight_smile:

Is there an alternative, more generic, “any-git-repository” plugin?

What does this mean?

I mean to automate the following relationship between Discourse and an arbitrary git repo:

… and to grant badges based on contributions in the repo:

Does it make any sense?
Sorry for not being clear in the original post.

I think this plugin could be much more useful if the number of PRs could be configured in settings for each kind of badge.

I’m refering to these 2 values

  • silver badge:
  • gold badge

Another useful feature could be that the badges granter could use the same repositories (more specifically the username/* notation) as the linkback part.

7 Likes

From this post:

“Here’s link 1, here’s link 2, and link 3.”

The original text of the link looked like this:

Here's [link 1](https://github.com/rust-lang/rfcs/blob/master/text/0002-rfc-process.md), here's [link 2](https://github.com/apple/swift-evolution/blob/master/process.md), and [link 3](http://bittorrent.org/beps/bep_0001.html).

It was turned into this pile of wrongness

Here's [link 1](https://github.com/apple/swift-evolution/blob/6065aef88c7b45c9a588cd481450c5dadb943117/process.md), here's [link 2](https://github.com/apple/swift-evolution/blob/master/process.md), and [link 3](http://bittorrent.org/beps/bep_0001.html).

Notice how it took the permalink of link 2, and copied it into link 1.

4 Likes

@maja can add that to your list?

3 Likes
4 Likes

This should be fixed per

Thanks for reporting!

5 Likes

This plug-in searches for accepted PRs by grepping the git log for commits with “Merge pull request” in the git message. However, this is not at all a reliable way to check for merges. It will only work when PRs are merged from the GitHub website, and only when using the “Create a merge commit” strategy, which represents a tiny minority of PR merges in our repository. For example, a fast-forward merge won’t be picked up even though GitHub regards it as perfectly valid. Somehow, I ended up with no counted contributions on a repo I am the primary contributor of.

Maybe this should be using the GitHub PR API instead? I don’t think it’s possible to do this simply by parsing git log.

Alternatively, perhaps there should be badges should be based on the number of commits (using the author field to check authorship) instead? It sounds like this would be a lot easier to get right.

4 Likes

Yeah I support moving this to use GitHub API if you want to give it a shot. Would need an internal cache of sorts cause you don’t want to walk through every PR ever, every N hours.

1 Like

Glad to see a PR recently added to use the GitHub API for badges thanks to @Osama.

I know that previously @codinghorror has said that issue linkback support won’t be added as Discourse doesn’t use GitHub issues but we at Home Assistant do with no plans to migrate away from GitHub issues anytime soon (no matter how much we love Discourse!). Would a PR be accepted if I submitted one to enable linkbacks for issues too? I’d be more than happy to make it opt in via a setting.

3 Likes

I am not against adding this as a default off option, but first i want to see a mock of how this would work.

  1. How will it look on GitHub?

  2. What site settings are you talking about adding.

2 Likes
  1. I think it would look exactly the same as it does on a PR. Just a comment on the issue with the same text (This issue has been mentioned on Discourse Meta. There might be relevant details there.\n\n\<link>). Maybe you are thinking of a reason that you may think that text would need to change as it’s extremely likely I am not thinking all reasons through.

  2. I’d say just one setting titled “github linkback on issues enabled” with a checkbox.

3 Likes

Hi there :wave: first post on the discourse meta discourse… thanks for making a wonderful product!

I’m just here to offer my :+1: for GitHub Issue linkbacks. This would be huge for my team!

4 Likes