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

Special character sequences in git commands #32

Open
El-Gor-do opened this issue Apr 19, 2022 · 1 comment
Open

Special character sequences in git commands #32

El-Gor-do opened this issue Apr 19, 2022 · 1 comment

Comments

@El-Gor-do
Copy link

El-Gor-do commented Apr 19, 2022

This is for other people's future reference. I was using the MSBuildGitHash Nuget package v2.0.2.

While trying to run some custom git commands to capture additional information, I ran into problems with character sequences that needed to be escaped.

  • % needs to be escaped as %%
  • ae needs to be escaped as a%e
  • cd needs to be escaped as c%d

These are the git commands I was trying to run:

  • git show --quiet --format=%ae
  • git show --quiet --format=%an
  • git show --quiet --format=%cd --date=iso-strict
  • git show --quiet --format=%B
  • git show --quiet --format=%H

This is the corresponding ItemGroup with correctly escaped character sequences:

  <ItemGroup>
    <AssemblyMetadataCommand Include="GitAuthorEmail">
      <Command>git show --quiet --format=%%a%e</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitAuthorName">
      <Command>git show --quiet --format=%%an</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitCommitDate">
      <Command>git show --quiet --format=%%c%d --date=iso-strict</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitCommitMessage">
      <Command>git show --quiet --format=%%B</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitFullHash">
      <Command>git show --quiet --format=%%H</Command>
    </AssemblyMetadataCommand>
  </ItemGroup>

There may be other character sequences that require escaping which I am not yet aware of.

@MarkPflug
Copy link
Owner

If you want to add a brief description about this to the readme.md, I will merge it.

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

2 participants