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

<commit-ish> parsing does not recognize @ as HEAD #702

Open
KalleOlaviNiemitalo opened this issue Dec 21, 2021 · 6 comments
Open

<commit-ish> parsing does not recognize @ as HEAD #702

KalleOlaviNiemitalo opened this issue Dec 21, 2021 · 6 comments

Comments

@KalleOlaviNiemitalo
Copy link

With nbgv 3.4.244+c60a07221c, nbgv get-version @ claims "rev-parse produced no commit for @", even though git rev-parse @ treats @ as equivalent to HEAD as documented in git-rev-parse(1).

Microsoft Windows [Version 10.0.19044.1415]
(c) Microsoft Corporation. All rights reserved.

C:\Projects>mkdir commit-ish-parsing

C:\Projects>cd commit-ish-parsing

C:\Projects\commit-ish-parsing>git init
Initialized empty Git repository in C:/Projects/commit-ish-parsing/.git/

C:\Projects\commit-ish-parsing>nbgv install

C:\Projects\commit-ish-parsing>git status
starting fsmonitor-daemon in 'C:/Projects/commit-ish-parsing'
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Directory.Build.props
        new file:   version.json


C:\Projects\commit-ish-parsing>git commit -m "nbgv install"
[master (root-commit) 84f4f71] nbgv install
 2 files changed, 22 insertions(+)
 create mode 100644 Directory.Build.props
 create mode 100644 version.json

C:\Projects\commit-ish-parsing>copy nul dummy
        1 file(s) copied.

C:\Projects\commit-ish-parsing>git add dummy

C:\Projects\commit-ish-parsing>git commit -m dummy
[master c4fd226] dummy
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dummy

C:\Projects\commit-ish-parsing>nbgv get-version
Version:                      1.0.2.64964
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.2-beta+c4fd226c01
NuGetPackageVersion:          1.0.2-beta
NpmPackageVersion:            1.0.2-beta

C:\Projects\commit-ish-parsing>nbgv get-version @
rev-parse produced no commit for @

C:\Projects\commit-ish-parsing>nbgv get-version HEAD
Version:                      1.0.2.64964
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.2-beta+c4fd226c01
NuGetPackageVersion:          1.0.2-beta
NpmPackageVersion:            1.0.2-beta

C:\Projects\commit-ish-parsing>git rev-parse @
c4fd226c0169d5f05e10030513c60c376ed565ae

C:\Projects\commit-ish-parsing>nbgv --version
3.4.244+c60a07221c

C:\Projects\commit-ish-parsing>
@KalleOlaviNiemitalo
Copy link
Author

KalleOlaviNiemitalo commented Dec 21, 2021

Likewise nbgv get-version "HEAD@{2 minutes ago}".

@AArnott
Copy link
Collaborator

AArnott commented Dec 22, 2021

This would have regressed when we switched from using libgit2 to our own managed git implementation.
I didn't know about @ and we could trivially add support for that. But the @{2 minutes ago} syntax, along with many other variants of the ~ so ^ characters, are probably beyond what we'd want to recreate support for given how rarely they're used with nbgv.

If @GlebChili decides to add support for any or all of these syntaxes in https://github.com/GlebChili/ManagedGitLib, that would be a good reason to consider switching from our private implementation to that one.

@KalleOlaviNiemitalo
Copy link
Author

I didn't know about @ and we could trivially add support for that.

Perhaps not so trivially:

$ nbgv get-version @~
Response file not found '~'

get-version:
  Gets the version information for a project.

Usage:
  nbgv get-version [options] [<commit-ish>]

Arguments:
  <commit-ish>    The commit/ref to get the version information for. [default: HEAD]

Options:
  -p, --project <project>      The path to the project or project directory. The default is the current directory.
  --metadata <metadata>        Adds an identifier to the build metadata part of a semantic version. [default: System.String[]]
  -f, --format <json|text>     The format to write the version information. Allowed values are: text, json. The default is text.
  -v, --variable <variable>    The name of just one version property to print to stdout. When specified, the output is always in raw text. Useful in scripts.
  -?, -h, --help               Show help and usage information

I guess the response-file feature comes from System.CommandLine. It does not seem very valuable for nbgv, though.

@KalleOlaviNiemitalo
Copy link
Author

(Incidentally, System.CommandLine 2.0.0-beta2.21617.1 is now available. It has some breaking changes as described in dotnet/command-line-api#1537.)

@GlebChili
Copy link
Contributor

I have opened a corresponding issue for ManagedGitLib: GlebChili/ManagedGitLib#6

I will try to implement a full support for the revision specification syntax in question, but I'm not sure how fast can I do it.

@KalleOlaviNiemitalo
Copy link
Author

I guess this is somewhat of a duplicate of #572.

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

No branches or pull requests

3 participants