-
Notifications
You must be signed in to change notification settings - Fork 215
[code-simplifier] Simplify serverHost extraction in push_repo_memory.cjs #16182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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?:\/\//, ""); | ||
|
|
||
| // Log environment variable configuration for debugging | ||
| core.info("Environment configuration:"); | ||
|
|
@@ -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
|
||
|
|
@@ -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) { | ||
|
|
@@ -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`); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serverHostderivation doesn’t trim a trailing slash fromGITHUB_SERVER_URL. IfGITHUB_SERVER_URLis set to something likehttps://ghe.example.com/, this produces...@ghe.example.com//owner/repo.gitremote URLs. Consider normalizing first (e.g., remove a trailing/) before building git URLs for consistency with other host-resolution code in the repo.