Skip to content

Instantly share code, notes, and snippets.

View mickmister's full-sized avatar
🔨
Building

Michael Kochell mickmister

🔨
Building
View GitHub Profile
@mickmister
mickmister / github_pr_view_changes_between_commits.md
Last active May 20, 2024 15:16
Bookmarklet to emulate "View Changes" button in GitHub PR review

I find the "View Changes" feature on GitHub PRs really useful - the button that essentially says "open the 'Files Changed' tab, comparing the current HEAD with the last commit I reviewed". This allows you to comment on exact changes that were made between now and the previous review. This button disappears after clicking it though, and (AFAIK) there's no easy way to access this functionality after the button disappears.

image

The URL format from clicking this button can be created manually, so you can choose to compare two different commits in the context of a PR review. The URL looks something like this:

https://github.com/mattermost/mattermost-plugin-github/pull/779/files/14c9e8b..0dfcb28

https://github.com/mattermost/mattermost-plugin-github/pull/779/files/14c9e8b..HEAD
@mickmister
mickmister / scrape_new_plugins.sh
Last active April 18, 2024 20:24
This bash script checks if there are any new plugins added to the Mattermost plugin marketplace, and creates a new post through a Mattermost incoming webhook request. See the comment below for more details.
#!/usr/bin/env bash
if [ -z "$MM_WEBHOOK_URL" ]
then
echo "Please set the MM_WEBHOOK_URL environment variable"
exit 0
fi
LOCAL_PLUGINSJSON_PATH="plugins.json"
REMOTE_PLUGINSJSON_PATH="new_plugins.json"
@mickmister
mickmister / mattermost_theme_switcher_bookmarklet.md
Last active February 22, 2024 16:55
Mattermost Theme Switcher Bookmarklet

A Bookmarklet to easily switch between themes in Mattermost.

The following pieces of code can be used as a bookmark URL to change your user's theme. You can copy each of these scripts into individual bookmarks in your browser. Clicking the bookmark will then change your user's theme to that value, and you should immediately see the changes in the UI.

For ease of use, you can create a folder in your bookmarks to store these, and have a bookmark for each of the following themes.

javascript: (() => {const bookmarkletTheme = 'Indigo'; fetch("/api/v4/users/me", {"headers": {"x-requested-with": "XMLHttpRequest"},"referrerPolicy": "no-referrer","mode": "cors","credentials": "include"}).then(r => r.json()).then(user => fetch("/api/v4/users/" + user.id + "/preferences", {"headers": {"x-requested-with": "XMLHttpRequest"},"body": "[{\"user_id\":\"" + user.id + "\",\"category\":\"theme\",\"name\":\"\",\"value\":\"{\\\"type\\\":\\\"" + bookmarkletTheme + "\\\",\\\"side
@mickmister
mickmister / mock_kv_store.go
Last active February 15, 2024 08:07
Mock KVStore for Mattermost plugin unit testing
package main
import (
"github.com/mattermost/mattermost/server/public/plugin/plugintest"
"github.com/stretchr/testify/mock"
)
type testKVStore map[string][]byte
func makeTestKVStore(api *plugintest.API, initialValues testKVStore) testKVStore {

You'll need to unmute the video to hear the audio

create-post-with-buttons.mp4

Uploads a plugin CI artifact to a Mattermost server. You can modify the plugin-install-gh-artifact.sh how you see fit, to connect with your MM admin account.

First you'll need to install and configure the GitHub CLI tool https://cli.github.com

Usage:

./plugin-install-gh-artifact.sh (MM site URL) (actions workflow run URL)
@mickmister
mickmister / go.mod
Last active May 18, 2023 14:50
Mattermost - Remove user from all teams and channels
module remove-channel-members
go 1.19
require (
github.com/mattermost/mattermost-server/server/public v0.0.4
github.com/pkg/errors v0.9.1
)
require (
@mickmister
mickmister / how_to_debug_playwright_logs.md
Last active February 15, 2024 08:14
Debugging Playwright tests in CI using verbose logging

Sometimes a Playwright test will run and pass correctly locally, but will fail when running in CI. We can debug the test using Playwright's verbose logging, and compare the output from both environments.

By setting the DEBUG env var to pw:api, Playwright runs the tests in verbose logging mode:

DEBUG=pw:api npm test

which produces output like this:

@mickmister
mickmister / create-plugin-dot-release.sh
Last active October 31, 2022 23:12
Script to automate creating a Mattermost plugin dot release off of the plugin's previous release
#!/bin/bash
REPO=$1
PREVIOUS_RELEASE=$2
NEXT_RELEASE=$3
ARGS="$*"
COMMITS=$(echo "$ARGS" | cut -f 4- -d" ")
[ ! -d "./$REPO" ] && git clone https://github.com/mattermost/${REPO}.git
@mickmister
mickmister / open-cypress.sh
Last active January 31, 2022 19:00
Open a cypress testing environment for a given plugin pull request
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Please provide a PR url, and a folder to expect a cypress testing suite. For example:
./open-cypress.sh https://github.com/mattermost/mattermost-plugin-github/pull/528 tests-e2e"
return 0
fi
if [[ -z "${MM_SERVICESETTINGS_SITEURL}" ]]; then