Skip to content

Extended feature descriptions

Kid edited this page Sep 25, 2025 · 16 revisions

pr-branch-auto-delete

After clicking "Merge", this feature will attempt automatically deleting the head branch to keep the repository clean. The deletion doesn't happen when:

  • You don't have permission to delete the branch (e.g. it has branch protections or it's from a fork)
  • The branch name matches one of the exceptions (e.g. prod, develop, see the full list in the feature source)
  • There are open PRs pointing to said branch

Tip

You should protect branches that aren't meant to ever be deleted. Murphy's Law.

Important

If you don't like this feature, disable it. Do not open requests or PRs to add or customize the list of exceptions.

clear-pr-merge-commit-message

On PRs, when squashing, the commit description is filled with every commit's title.

If you squash, probably aren't interested in every commit's title and should therefore be dropped. If they're useful, maybe you should merge or rebase instead.

Note

This feature overrides any related GitHub settings. Please disable the feature if that's not what you want.

closing-remarks

The feature asks GitHub what tags the merge commit appears in and it will show the first one in the list. Number-less tags and "nightly" tags are excluded.

There are a number of limitations we face:

  • Tags are sorted alphabetically, the first one is picked. If you tag your repo consistently this is not an issue
  • The sorting cannot be changed, we just fetch it from GitHub
  • The exact merge commit needs to appear under the tag, rebased commits are ignored

new-repo-disable-projects-and-wikis

Projects and wikis are used by a minority of users so Refined GitHub defaults to disabling them when creating a new repo. This can be avoided by unticking the checkbox before creating a new repo.

prevent-link-loss

GitHub has this really annoying bug that changes pull request commit links:

https://github.com/sindresorhus/refined-github/pull/3/commits/cb44a4eb8cd5c66def3dc26dca0f386645fa29bb

into non-pull-request-related links like:

https://github.com/sindresorhus/refined-github/commit/cb44a4eb8cd5c66def3dc26dca0f386645fa29bb

This bug applies to raw URLs but not URLs that are already part of a Markdown link, like:

[my commit](https://github.com/sindresorhus/refined-github/pull/3/commits/cb44a4eb8cd5c66def3dc26dca0f386645fa29bb)

Refined GitHub's prevent-link-loss feature will prompt you to fix this link and you can do so with a click:

demo gif

html-preview-link

This feature uses refined-github-html-preview.kidonng.workers.dev, a service hosted on Cloudflare Workers provided by us without warranty.

Source Code
const pattern = new URLPattern({ pathname: "/:user/:repo/raw/:path(.+)" });

export default {
  async fetch(request) {
    const { url } = request;
    const result = pattern.exec(url);

    if (!result) {
      const { pathname } = new URL(url);
      if (pathname === "/") {
        return Response.redirect(
          "https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#html-preview-link",
        );
      }

      return new Response("Bad Request", { status: 400 });
    }

    const { user, repo, path } = result.pathname.groups;
    const response = await fetch(
      `https://raw.githubusercontent.com/${user}/${repo}/${path}`,
      request,
    );
    const headers = new Headers(response.headers);

    // Set correct content type
    // Original: text/plain; charset=utf-8
    if (url.endsWith(".htm") || url.endsWith(".html")) {
      headers.set("content-type", "text/html; charset=utf-8");
    } else if (url.endsWith(".css")) {
      headers.set("content-type", "text/css; charset=utf-8");
    } else if (url.endsWith(".js")) {
      headers.set("content-type", "application/javascript; charset=utf-8");
    }

    // Disable CSP
    // Original: default-src 'none'; style-src 'unsafe-inline'; sandbox
    headers.delete("content-security-policy");

    // Disable crawling
    // https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag#xrobotstag
    headers.set("x-robots-tag", "none");

    return new Response(response.body, {
      headers,
      status: response.status,
      statusText: response.statusText,
    });
  },
};

filler to allow extra scroll

Clone this wiki locally