walkdiff 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.7.1
6
+
7
+ - **Works with git configs that route https to ssh:** a `url.*.insteadOf` rule that sends `https://gitlab.com/` or `https://github.com/` to ssh, common for cargo or go with private repositories, made reviews fail with "transport 'ssh' not allowed". Walkdiff's own fetch now stays on https with its token, and the rule still applies to everything else.
8
+
5
9
  ## 0.7.0
6
10
 
7
11
  - **Progress while a review is analyzed:** the app shows a bar with the step under way, such as "Step 6 of 9: Scanning for security problems", instead of only "Analyzing…". The command line prints each step as it starts, so CI logs show where a slow run is.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  A review companion for GitHub pull requests and GitLab merge requests. `walkdiff review <url>` fetches the
6
6
  change, analyzes it, and serves a local report. (Working name; the project name is still an open decision.)
7
7
 
8
- Status: early release, [v0.7.0](CHANGELOG.md). To run it on your team's PRs, see the [pilot guide](docs/pilot.md).
8
+ Status: early release, [v0.7.1](CHANGELOG.md). To run it on your team's PRs, see the [pilot guide](docs/pilot.md).
9
9
 
10
10
  **Documentation:** [getting started](docs/getting-started.md), [configuration](docs/configuration.md), [troubleshooting](docs/troubleshooting.md), [security policy](SECURITY.md).
11
11
 
@@ -98,7 +98,7 @@ Tokens and code stay on your machine, apart from the host itself, package names
98
98
 
99
99
  ## In CI
100
100
 
101
- The GitHub Action (`navasvarela/walkdiff@v0.7.0`) and the GitLab template (`ci/gitlab-ci.yml`) generate the report for each PR, keep it as a job artifact, and post one summary comment that is updated on each push. The [pilot guide](docs/pilot.md) has the setup. Locally, `walkdiff review` also works without a URL inside a CI job, and `walkdiff comment --report <dir> --report-url <url>` posts the summary.
101
+ The GitHub Action (`navasvarela/walkdiff@v0.7.1`) and the GitLab template (`ci/gitlab-ci.yml`) generate the report for each PR, keep it as a job artifact, and post one summary comment that is updated on each push. The [pilot guide](docs/pilot.md) has the setup. Locally, `walkdiff review` also works without a URL inside a CI job, and `walkdiff comment --report <dir> --report-url <url>` posts the summary.
102
102
 
103
103
  ## AI review
104
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "walkdiff",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "A review companion for GitHub pull requests and GitLab merge requests",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
package/walkdiff.mjs CHANGED
@@ -107,7 +107,7 @@ async function fetchCommits(request) {
107
107
  ...refspecs
108
108
  ], {
109
109
  cwd: repoDir,
110
- env: credentialEnv(request.credentials)
110
+ env: fetchEnv(request.cloneUrl, request.credentials)
111
111
  });
112
112
  const stillMissing = await missingCommits(repoDir, missing);
113
113
  if (stillMissing.length > 0) throw new MissingCommitsError(stillMissing, request.cloneUrl);
@@ -136,18 +136,33 @@ async function missingCommits(repoDir, commits) {
136
136
  return commits.filter((_, index) => present.at(index) !== true);
137
137
  }
138
138
  const ALLOWED_PROTOCOLS = "https:http";
139
- function credentialEnv(credentials) {
140
- if (credentials === void 0) return { GIT_ALLOW_PROTOCOL: ALLOWED_PROTOCOLS };
141
- const basic = Buffer.from(`${credentials.username}:${credentials.token}`).toString("base64");
139
+ /**
140
+ * The fetch keeps the person's git config, for proxies and credential helpers, with three
141
+ * additions:
142
+ * - A rewrite of the clone URL to itself. People route https to ssh with `url.*.insteadOf`,
143
+ * for cargo or go with private repositories, and that rewrite would carry this fetch to a
144
+ * transport ALLOWED_PROTOCOLS refuses. Git applies the longest matching `insteadOf`, and
145
+ * the full URL is longer than any prefix rule that matches it, so this one wins and the
146
+ * fetch stays on https, with its token.
147
+ * - The token as an `Authorization` header, through GIT_CONFIG_* variables rather than `-c`
148
+ * arguments or the remote URL, which keeps it out of `ps` output and the repository's config.
149
+ * - No redirects, because git would send that header to wherever one points.
150
+ */
151
+ function fetchEnv(cloneUrl, credentials) {
152
+ const entries = [[`url.${cloneUrl}.insteadOf`, cloneUrl]];
153
+ if (credentials !== void 0) {
154
+ const basic = Buffer.from(`${credentials.username}:${credentials.token}`).toString("base64");
155
+ entries.push(["http.extraHeader", `Authorization: Basic ${basic}`], ["http.followRedirects", "false"]);
156
+ }
142
157
  return {
143
158
  GIT_ALLOW_PROTOCOL: ALLOWED_PROTOCOLS,
144
- GIT_CONFIG_COUNT: "2",
145
- GIT_CONFIG_KEY_0: "http.extraHeader",
146
- GIT_CONFIG_VALUE_0: `Authorization: Basic ${basic}`,
147
- GIT_CONFIG_KEY_1: "http.followRedirects",
148
- GIT_CONFIG_VALUE_1: "false"
159
+ ...configEnv(entries)
149
160
  };
150
161
  }
162
+ function configEnv(entries) {
163
+ const numbered = entries.flatMap(([key, value], index) => [[`GIT_CONFIG_KEY_${index}`, key], [`GIT_CONFIG_VALUE_${index}`, value]]);
164
+ return Object.fromEntries([["GIT_CONFIG_COUNT", String(entries.length)], ...numbered]);
165
+ }
151
166
  async function exists(path) {
152
167
  try {
153
168
  await access(path);