Skip to content
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

Get wrong tag from gitcl describe with match_pattern in Windows #402

Open
zwpaper opened this issue Jan 26, 2025 · 0 comments
Open

Get wrong tag from gitcl describe with match_pattern in Windows #402

zwpaper opened this issue Jan 26, 2025 · 0 comments

Comments

@zwpaper
Copy link

zwpaper commented Jan 26, 2025

We use vergen-gitcl to get the latest v* tag and build it into binary,
but found it was wrong on Windows, getting the commit sha instead of tags.

we dig into the implementation of vergen-gitcl and found it uses cmd to get the result:

#[cfg(target_env = "msvc")]
fn run_cmd(command: &str, path_opt: Option<&PathBuf>) -> Result<Output> {
let mut cmd = Command::new("cmd");
if let Some(path) = path_opt {
_ = cmd.current_dir(path);
}
_ = cmd.arg("/c");
_ = cmd.arg(command);
_ = cmd.stdout(Stdio::piped());
_ = cmd.stderr(Stdio::piped());
Ok(cmd.output()?)
}

with match_pattern, gitcl will add the --match "v*" as args, notice the quotes within it.

if let Some(pattern) = self.describe_match_pattern {
describe_cmd.push_str(" --match \"");
describe_cmd.push_str(pattern);
describe_cmd.push('\"');
}

but as the cmd lib says, all Windows arguments are passed as a single commandline string:

Image

and we did some experiments:

Image

it seems the current implementation can not get the right tag due to the quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant