Skip to content

feat: add support for github enterprise instances - #65

Open
jsngalloway wants to merge 3 commits into
silvanocerza:mainfrom
jsngalloway:jg/set-host
Open

feat: add support for github enterprise instances#65
jsngalloway wants to merge 3 commits into
silvanocerza:mainfrom
jsngalloway:jg/set-host

Conversation

@jsngalloway

Copy link
Copy Markdown

This PR adds support for this plugin to communicate with self-hosted github instances. It does this by removing the hardcoded github.com and prompting the user fill in the full URL of the repo.

  • tested this with a Github enterprise server
  • tested with github.com for sanity
  • tested migrating a github.com vault to the new settings - the update is transparent to the user, it assumes github.com since that was the only thing supported before

Here's what the config page looks like now:

  • repository url - the full url of the repo e.g. https://github.com/jsngalloway/github-gitless-sync
  • api base url - in the case that your github enterprise server vends its API on a differnet url, you can specify this here - otherwise it'll be inferred from the repository URL. I think the cases in which this are used will be very few and would consider removing if you think this is confusing.
image

There's some handy rejection logic:

image

Here's some logs that show it's interacting with a github enterprise server:

{"timestamp":"2026-08-30T22:01:43.050Z","level":"INFO","message":"Loading metadata"}
{"timestamp":"2026-08-30T22:01:43.054Z","level":"INFO","message":"Loaded metadata"}
{"timestamp":"2026-08-30T22:01:55.322Z","level":"INFO","message":"Starting first sync"}
{"timestamp":"2026-08-30T22:01:56.050Z","level":"ERROR","message":"Failed to get repo content","additional_data":{"status":409,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-length":"162","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Sun, 30 Aug 2026 22:01:55 GMT","github-authentication-token-expiration":"2026-09-29 17:31:19 -0400","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains","x-accepted-github-permissions":"contents=read","x-content-type-options":"nosniff","x-github-api-version-selected":"2022-11-28","x-github-enterprise-version":"3.20.6","x-github-media-type":"github.v3; format=json","x-github-request-id":"8ba0f9d5-7f00-4f86-808c-771ced185175","x-ratelimit-limit":"150000","x-ratelimit-remaining":"149999","x-ratelimit-reset":"1788130915","x-ratelimit-resource":"core","x-ratelimit-used":"1","x-xss-protection":"0"},"arrayBuffer":{},"json":{"message":"Git Repository is empty.","documentation_url":"https://docs.github.com/enterprise-server@3.20/rest/git/trees#get-a-tree","status":"409"},"text":"{\n  \"message\": \"Git Repository is empty.\",\n  \"documentation_url\": \"https://docs.github.com/enterprise-server@3.20/rest/git/trees#get-a-tree\",\n  \"status\": \"409\"\n}\n"}}
{"timestamp":"2026-08-30T22:01:56.050Z","level":"INFO","message":"Remote repository is empty"}
{"timestamp":"2026-08-30T22:01:56.961Z","level":"INFO","message":"Starting first sync from local files"}
{"timestamp":"2026-08-30T22:01:58.134Z","level":"INFO","message":"Sync done"}

Comment thread src/github/client.ts
const response = await retryUntil(
async () => {
return requestUrl({
url: `https://api.github.com/repos/${this.settings.githubOwner}/${this.settings.githubRepo}/git/trees/${this.settings.githubBranch}?recursive=1`,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes hardcoded urls

@jsngalloway
jsngalloway marked this pull request as ready for review August 30, 2026 22:50
Comment on lines +1 to +5
import test from "node:test";
import * as assert from "node:assert/strict";
import { resolveRepoTarget } from "./repo-url";

test("resolves repository URLs", () => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests for sanity of URL parsing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant