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

Regression: cannot parse commitishes like HEAD~2 #572

Open
heaths opened this issue Mar 28, 2021 · 3 comments
Open

Regression: cannot parse commitishes like HEAD~2 #572

heaths opened this issue Mar 28, 2021 · 3 comments

Comments

@heaths
Copy link
Contributor

heaths commented Mar 28, 2021

nbgv version 3.3.37+0989e8fe0c could parse commitishes like HEAD~2 but the latest version build from master cannot. It yields an exception:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(ReadOnlySpan`1 str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(ReadOnlySpan`1 s, NumberStyles style, NumberFormatInfo info)
   at System.Byte.Parse(ReadOnlySpan`1 s, NumberStyles style, NumberFormatInfo info)
   at System.Byte.Parse(String s, NumberStyles style, IFormatProvider provider)
   at Nerdbank.GitVersioning.ManagedGit.GitRepository.ConvertHexStringToByteArray(String hexString) in C:\src\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\ManagedGit\GitRepository.cs:line 724
   at Nerdbank.GitVersioning.ManagedGit.GitRepository.Lookup(String objectish) in C:\src\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\ManagedGit\GitRepository.cs:line 405
   at Nerdbank.GitVersioning.Managed.ManagedGitContext.TrySelectCommit(String committish) in C:\src\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\Managed\ManagedGitContext.cs:line 66
   at Nerdbank.GitVersioning.Tool.Program.OnGetVersionCommand(String projectPath, IReadOnlyList`1 buildMetadata, String format, String singleVariable, String versionOrRef) in C:\src\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 330
   at Nerdbank.GitVersioning.Tool.Program.MainInner(String[] args) in C:\src\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 165
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Nerdbank.GitVersioning.Tool.Program.Main(String[] args) in C:\src\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 76
@AArnott
Copy link
Collaborator

AArnott commented Mar 28, 2021

This is an expected regression from #521 (CC: @qmfrederik). We only support (partial) commit IDs and refs at this point unless you explicitly. You should be able to workaround it by switching to the libgit2 engine as described in our release notes.

Supporting all the various committish forms in the all-managed engine would be a large undertaking I suspect. I am curious why you were doing this and how often you anticipate hitting this.

@heaths
Copy link
Contributor Author

heaths commented Mar 29, 2021

Was trying various scenarios using the latest nbgv global tool release and what I had in my branch for #567. For a while, I thought somehow my code changes broke this (something to do with the parsing), but after stashing and switching back to master, found it was broken before (same as with the other bug).

If it's not supported, I understand. But might want to catch the issue and gracefully error or throw a new exception with a more friendly error. The error message itself isn't obvious unless you look further down the stack, and not everyone using nbgv may find that so easy.

@qmfrederik
Copy link
Contributor

Looking from the docs, there are two types of Ancestry References
which are supported:

  • a ^ (caret) for the parent of a commit, or ^n for the nth parent of a commit (if that commit has multiple parent)
  • the ~ (tilde), optionally followed by an integer.

So you can have HEAD, HEAD^, HEAD^2, HEAD~ or HEAD~n. These can be combined, so you can have something like HEAD~3^2.

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

3 participants