feat: support github enterprise#607
Merged
Merged
Conversation
ponkio-o
commented
Feb 3, 2025
Comment on lines
+163
to
+165
| if flags.GHEBaseURL == "" { | ||
| flags.GHEBaseURL = os.Getenv("GITHUB_API_URL") | ||
| } |
Contributor
Author
There was a problem hiding this comment.
The GITHUB_API_URL has https://<hostname>/api/v3 style, but auto injected /api/v3 suffix when without URL path (and trailing slash) by WithEnterpriseURLs() method.
So, users can use both style:
- GITHUB_API_URL=https://github.example.jp, https://github.example.jp/
- GITHUB_API_URL=https://github.example.jp/api/v3, https://github.example.jp/api/v3/
Owner
|
Thank you for your contribution! |
Owner
|
Did you confirm that this works well? |
Contributor
Author
Yes. I confirmed working correctly with below commands on our GHES. $ export GITHUB_TOKEN=$(gh auth token --hostname <GHES_HOST>
$ go run ./cmd/mkghtag/main.go -owner <OWNER> -repo <REPO> -sha d8899dbcc664831276a2b3b6451b75110813a477 -ghe-base-url <GHES_HOST> v0.0.1
INFO[0000] creating a reference mkghtag_version= program=mkghtag repo_name=<REPO> repo_owner=<OWNER> sha=d8899dbcc664831276a2b3b6451b75110813a477 tag=v0.0.1
INFO[0000] creating a tag mkghtag_version= program=mkghtag repo_name=<REPO> repo_owner=<OWNER> sha=d8899dbcc664831276a2b3b6451b75110813a477 tag=v0.0.1 |
Owner
|
Thank you. Looks good. |
suzuki-shunsuke
added a commit
to suzuki-shunsuke/go-pr-diff
that referenced
this pull request
Apr 15, 2026
* TestClient_GetDiff_aquaRegistryPR fetches the diff for aquaproj/aqua-registry#51977 via the GitHub API. Honors GITHUB_TOKEN to avoid rate limits. * TestClient_gitFallback_mkghtagPR exercises the git shell-out path against suzuki-shunsuke/mkghtag#607 (chosen for its tiny repo size to keep the dangling-objects pollution of the local .git negligible). * Both tests skip in -short mode and when git is not on PATH. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
suzuki-shunsuke
added a commit
to suzuki-shunsuke/go-pr-diff
that referenced
this pull request
Apr 15, 2026
* TestClient_GetDiff_mkghtagPR (renamed from _aquaRegistryPR) now uses the same PR (suzuki-shunsuke/mkghtag#607) as the gitFallback test. * Both integration tests load a fixture from testdata/ and compare the full diff with cmp.Diff instead of substring matching. * Two fixtures are kept because the GitHub API and local `git diff` produce different abbreviation lengths in `index <hash>..<hash>` lines (GitHub uses the upstream repo's auto-abbrev; local git uses the host repo's). Diff bodies are otherwise identical. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
suzuki-shunsuke
added a commit
to suzuki-shunsuke/go-pr-diff
that referenced
this pull request
Apr 15, 2026
* feat: add prdiff package * feat: implement GetDiff with GitHub API and git fallback GetDiff now fetches the PR diff via the GitHub API (PullRequestsService.GetRaw), and falls back to local git commands when the API call fails. The fallback resolves base/head/merge-base via the API, runs shallow fetches, and runs `git diff base...head`, creating a temporary git repo if the cwd is not one. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: add unit tests for Client.GetDiff Covers the GitHub API success path and the API-failure + git-fallback-failure path using fakes injected via the existing prsService / reposService interfaces. Adds go-cmp as a test dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: simplify gitFallback for shallow fetches and head-fork deletion * Drop the explicit base SHA fetch; the diff GitHub shows for a PR is merge_base..head, so only those two commits need to be fetched. * Switch from `git diff base...head` (3-dot) to `git diff <merge_base> <head>` (2-dot). The 3-dot form invokes `git merge-base`, which fails with "no merge base" against the shallow fetches we make. * Always fetch through the base repo URL. GitHub's fork network keeps the head SHA reachable from the base repo, so the fallback still works after the head fork is deleted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: add integration tests for GetDiff and gitFallback * TestClient_GetDiff_aquaRegistryPR fetches the diff for aquaproj/aqua-registry#51977 via the GitHub API. Honors GITHUB_TOKEN to avoid rate limits. * TestClient_gitFallback_mkghtagPR exercises the git shell-out path against suzuki-shunsuke/mkghtag#607 (chosen for its tiny repo size to keep the dangling-objects pollution of the local .git negligible). * Both tests skip in -short mode and when git is not on PATH. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: assert full diff against fixture files for mkghtag PR * TestClient_GetDiff_mkghtagPR (renamed from _aquaRegistryPR) now uses the same PR (suzuki-shunsuke/mkghtag#607) as the gitFallback test. * Both integration tests load a fixture from testdata/ and compare the full diff with cmp.Diff instead of substring matching. * Two fixtures are kept because the GitHub API and local `git diff` produce different abbreviation lengths in `index <hash>..<hash>` lines (GitHub uses the upstream repo's auto-abbrev; local git uses the host repo's). Diff bodies are otherwise identical. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add ExampleClient_GetDiff Demonstrates Client.GetDiff usage in godoc by fetching the diff for suzuki-shunsuke/mkghtag#1080 (a tiny one-line dependency-bump PR chosen so the full diff fits cleanly in the example output for byte-exact verification). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: write GoDoc * chore: configure AI Agents * chore: configure golangci-lint * docs: update README * ci: set up --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
issue: #602