mattermost-plugin-github
                                
                                 mattermost-plugin-github copied to clipboard
                                
                                    mattermost-plugin-github copied to clipboard
                            
                            
                            
                        Code Previews not working with private repos
Hello,
I can't get code preview in any channels when I link a file from a private repo. I have no error messages when I set MM server to debug mode. It just send default Github public link metadata.
Mattermost Server team edition version 6.2.1
Github plugin 2.0.1
Code Previews enabled for public and private repositories in Github plugin configuration
Connected via /github connect private
Tested with a Dockerfile from a public and private repos
I tested reconnecting account to GH, disabling/enabling Code Preview
I don't know if I'm missing something, tell me if you need more information.
Hi @tuxity,
Did you enable code previews for public and private repositories in the plugins settings?
Yes it is enable.
To which options is the setting set?
to "Enable for public and private repositories. This might leak confidential code into public channels."
I can't reproduce the issue.
- Do you see any related error in the server logs?
- Is the repository you tested with part of a organisation?
I tried to put the server in debug mode and there is no error in logs I also tested with a private repo from an organisation and also one of my personal private repo and not working.
I also tried to disable and enable the plugin again, the plugin is not restricted to an organisation
Should I try to reinstall the plugin ? I will have to resetup every subscriptions in channels ?
Just to double check: You created the permalink by selecting the lines of code in the UI and clicking on Copy permalink?

Haven't tried this type of link, I was checking with URL in browser like
https://github.com/mattermost/mattermost-plugin-github/blob/master/Makefile
https://github.com/mattermost/mattermost-plugin-github/blob/master/Makefile#L27
(but with private repo ofc)
When I use permalink it's working correctly indeed.
https://github.com/mattermost/mattermost-plugin-github/blob/1068fe3eb5bf57b7c7cba22a43cc9491137a109a/Makefile#L12
So maybe the plugin isn't supposed to parse this type of URL for private repo ? The only difference is the commit id after /blob/ instead of the branch name
All my coworkers in my team use the URL from browser directly to reference a file, commit, PR... and we only get

Yes, that is indeed the expected behavior currently. https://github.com/mattermost/mattermost-plugin-github/blob/40e7fcf8bdfa2f49bae44b214ed96588ffe6c4df/server/plugin/permalinks.go#L96-L100
But I'm wondering if the plugin should support links to branches and tags. On caveat is that the content might change in the future and it's hard to keep the message in sync. So it would be a snapshot of the content at the time the message is posted.
@agnivade Do you have thoughts on this ideas, as you originally implemented the feature?
This feature is primarily supposed to work with permalinks, not with regular links. The original implementation mainly mirrored GitHub's permalink preview implementation. And as you can see from above, GitHub will also only expand permalinks, not all kinds of links.
This usually applies to all kinds of permalink previews - they are tied to a single id/hash. And not something that can change. Otherwise, this becomes a link preview, not permalink preview. We could do that of course, but then we deviate from the usual accepted standard.
As a first step, I'd suggest to document this more prominently, and how to capture and share permalinks, not regular links.
And to clarify, this has no relation to the type of repo - public/private. It only expands permalinks.
Made this a Help Wanted documentation ticket