-
Notifications
You must be signed in to change notification settings - Fork 539
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
fix(build-cli): Fix up-to-date branch check #23968
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -165,9 +165,11 @@ export class Repository implements GitContext { | |
public async getShaForBranch(branch: string, remote?: string): Promise<string> { | ||
const refspec = | ||
remote === undefined ? `refs/heads/${branch}` : `refs/remotes/${remote}/${branch}`; | ||
// result is a string of the form '64adcdba56deb16e0641c91ca825401a9f7a01f9 refs/heads/release/client/2.23' | ||
const result = await this.git.raw(`show-ref`, refspec); | ||
|
||
return result; | ||
const [sha] = result.split(" "); | ||
return sha; | ||
} | ||
|
||
/** | ||
|
@@ -465,7 +467,7 @@ export class Repository implements GitContext { | |
* Fetch branch | ||
*/ | ||
public async fetchBranch(remote: string, branchName: string): Promise<void> { | ||
await this.gitClient.fetch(remote, [branchName]); | ||
await this.gitClient.fetch(remote, branchName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we didn't catch this because there's a signature that can actually take a string array of options? Can we use the returned |
||
} | ||
} | ||
|
||
|
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.
I noticed this code has not changed in 2 years, and
git show-ref
also doesn't seem to have changed its output in the 2.x train of git... have we really been that lucky with this somehow still working?If we only care about the sha, I'd suggest we use
git show-ref --hash
, and that we also validate that the result contains a single line to be completely sure the sha is actually for the thing we intend.