feat: support fetching from private repositories #104

Merged
earl-warren merged 1 commit from earl-warren/release-notes-assistant:wip-git-token into main 2025-08-02 11:57:31 +00:00
Contributor

The token is set for Git to use if needed to read the repository, in a temporary script that echos it if needed. The script is set in the GIT_ASKPASS environement variable and will be used by Git when and if a password is required.

https://git-scm.com/docs/gitcredentials/2.50.0#_requesting_credentials

  • write the token in a temporary location deleted when the command completes
  • the fixtures are created in a private repository instead of a public one
  • a dedicated runGitReadRemote command is added and sets GIT_ASKPASS to the temporary script

If GIT_ASKPASS is commented out the tests fail as follows:

$ ./tests.sh rna_check |& tee /tmp/check
COVERAGE="-cover -coverprofile /tmp/coverage.out -coverpkg code.forgejo.org/forgejo/release-notes-assistant/..." make check
make[1]: Entering directory '/home/earl-warren/software/release-notes-assistant'
/home/earl-warren/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.5.linux-amd64/bin/go test  -cover -coverprofile /tmp/coverage.out -coverpkg code.forgejo.org/forgejo/release-notes-assistant/... code.forgejo.org/forgejo/release-notes-assistant/...
warning: ignoring symlink /home/earl-warren/software/release-notes-assistant/end-to-end/packages/alpine-7.0-dev
warning: ignoring symlink /home/earl-warren/software/release-notes-assistant/end-to-end/packages/alpine-7.0-dev
time=2025-08-02T13:48:08.599+02:00 level=DEBUG source=/home/earl-warren/software/release-notes-assistant/cli.go:181 msg="release-notes-assistant starting"
time=2025-08-02T13:48:08.600+02:00 level=INFO source=/home/earl-warren/software/release-notes-assistant/git.go:340 msg="git [clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone]"
time=2025-08-02T13:48:08.600+02:00 level=DEBUG source=/home/earl-warren/software/release-notes-assistant/exec.go:59 msg=git args="[clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone]"

--- FAIL: Test_cliRelease (0.01s)
panic: exit status 128: exit code: 128, Cloning into bare repository '/tmp/rna4282272902/clone'...
	fatal: could not read Username for 'http://192.168.3.6:3000': terminal prompts disabled
	, git, [clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone] [recovered]
The token is set for Git to use if needed to read the repository, in a temporary script that echos it if needed. The script is set in the GIT_ASKPASS environement variable and will be used by Git when and if a password is required. https://git-scm.com/docs/gitcredentials/2.50.0#_requesting_credentials - write the token in a temporary location deleted when the command completes - the fixtures are created in a private repository instead of a public one - a dedicated runGitReadRemote command is added and sets GIT_ASKPASS to the temporary script --- If `GIT_ASKPASS` is commented out the tests fail as follows: ```sh $ ./tests.sh rna_check |& tee /tmp/check COVERAGE="-cover -coverprofile /tmp/coverage.out -coverpkg code.forgejo.org/forgejo/release-notes-assistant/..." make check make[1]: Entering directory '/home/earl-warren/software/release-notes-assistant' /home/earl-warren/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.5.linux-amd64/bin/go test -cover -coverprofile /tmp/coverage.out -coverpkg code.forgejo.org/forgejo/release-notes-assistant/... code.forgejo.org/forgejo/release-notes-assistant/... warning: ignoring symlink /home/earl-warren/software/release-notes-assistant/end-to-end/packages/alpine-7.0-dev warning: ignoring symlink /home/earl-warren/software/release-notes-assistant/end-to-end/packages/alpine-7.0-dev time=2025-08-02T13:48:08.599+02:00 level=DEBUG source=/home/earl-warren/software/release-notes-assistant/cli.go:181 msg="release-notes-assistant starting" time=2025-08-02T13:48:08.600+02:00 level=INFO source=/home/earl-warren/software/release-notes-assistant/git.go:340 msg="git [clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone]" time=2025-08-02T13:48:08.600+02:00 level=DEBUG source=/home/earl-warren/software/release-notes-assistant/exec.go:59 msg=git args="[clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone]" --- FAIL: Test_cliRelease (0.01s) panic: exit status 128: exit code: 128, Cloning into bare repository '/tmp/rna4282272902/clone'... fatal: could not read Username for 'http://192.168.3.6:3000': terminal prompts disabled , git, [clone --mirror http://192.168.3.6:3000/root/fixture /tmp/rna4282272902/clone] [recovered] ```
feat: support fetching from private repositories
All checks were successful
/ test (pull_request) Successful in 6m43s
8d61886c55
The token is set for Git to use if needed to read the repository,
in a temporary script that echos it if needed. The script is set in
the GIT_ASKPASS environement variable and will be used by Git when
and if a password is required.

https://git-scm.com/docs/gitcredentials/2.50.0#_requesting_credentials

- write the token in a temporary location deleted when the command
  completes
- the fixtures are created in a private repository instead of a
  public one
- a dedicated runGitReadRemote command is added and sets
  GIT_ASKPASS to the temporary script
earl-warren deleted branch wip-git-token 2025-08-02 11:57:32 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
forgejo/release-notes-assistant!104
No description provided.