Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions actions/setup/js/push_repo_memory.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async function main() {
const ghToken = process.env.GH_TOKEN;
const githubRunId = process.env.GITHUB_RUN_ID || "unknown";
const githubServerUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

serverHost derivation doesn’t trim a trailing slash from GITHUB_SERVER_URL. If GITHUB_SERVER_URL is set to something like https://ghe.example.com/, this produces ...@ghe.example.com//owner/repo.git remote URLs. Consider normalizing first (e.g., remove a trailing /) before building git URLs for consistency with other host-resolution code in the repo.

Suggested change
const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
const serverHost = githubServerUrl.replace(/^https?:\/\//, "").replace(/\/+$/, "");

Copilot uses AI. Check for mistakes.

// Log environment variable configuration for debugging
core.info("Environment configuration:");
Expand Down Expand Up @@ -132,8 +133,6 @@ async function main() {
// Checkout or create the memory branch
core.info(`Checking out branch: ${branchName}...`);
try {
// Extract host from server URL (remove https:// prefix)
const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
const repoUrl = `https://x-access-token:${ghToken}@${serverHost}/${targetRepo}.git`;

// Try to fetch the branch
Comment on lines 136 to 138
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

repoUrl is still constructed three times with the same template (checkout/pull/push). Since ghToken, serverHost, and targetRepo are constant within main(), consider defining repoUrl once and reusing it to further reduce duplication and lower the chance of future inconsistencies.

See below for a potential fix:

  const repoUrl = `https://x-access-token:${ghToken}@${serverHost}/${targetRepo}.git`;
  try {

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -345,8 +344,6 @@ async function main() {
// Pull with merge strategy (ours wins on conflicts)
core.info(`Pulling latest changes from ${branchName}...`);
try {
// Extract host from server URL (remove https:// prefix)
const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
const repoUrl = `https://x-access-token:${ghToken}@${serverHost}/${targetRepo}.git`;
execGitSync(["pull", "--no-rebase", "-X", "ours", repoUrl, branchName], { stdio: "inherit" });
} catch (error) {
Expand All @@ -357,8 +354,6 @@ async function main() {
// Push changes
core.info(`Pushing changes to ${branchName}...`);
try {
// Extract host from server URL (remove https:// prefix)
const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
const repoUrl = `https://x-access-token:${ghToken}@${serverHost}/${targetRepo}.git`;
execGitSync(["push", repoUrl, `HEAD:${branchName}`], { stdio: "inherit" });
core.info(`Successfully pushed changes to ${branchName} branch`);
Expand Down