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-commits errors out while get-version works #1049

Open
macsux opened this issue May 7, 2024 · 3 comments
Open

Get-commits errors out while get-version works #1049

macsux opened this issue May 7, 2024 · 3 comments

Comments

@macsux
Copy link

macsux commented May 7, 2024

The nbgv successfully gives me the version number from get-version command

nbgv get-version
Version:                      1.0.8.50358
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.8+b6c4fd7948
NuGetPackageVersion:          1.0.8
NpmPackageVersion:            1.0.8

however, when I try to get commits via nbgv get-commits, I receive "" is not a simple a.b.c[.d] version spec.. It's unclear what is the issue

Here is the repo in question

@AArnott
Copy link
Collaborator

AArnott commented May 7, 2024

What exactly are you passing into get-commits? It requires an argument.

@macsux
Copy link
Author

macsux commented May 7, 2024

Ok, I'm an idiot, didn't realize this :)

But I have a follow up question. In this repo I have a folder called /lifecycle that has it's own version.json. I've added it on the last commit, and version is set to 1.0. When I run get-version, I'm getting 1.0.8 instead of expected 1.0.1. When I check it with get-commits, it returns only a single last commit, so I'm confused where the 8 height is coming from.

PS C:\projects\cf-buildpack-template\lifecycle> nbgv get-version
Version:                      1.0.8.50358
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.8+b6c4fd7948
NuGetPackageVersion:          1.0.8
NpmPackageVersion:            1.0.8
PS C:\projects\cf-buildpack-template\lifecycle> nbgv get-commits 1.0.8
b6c4fd79489a7a18a53fd024e4a640753fa0fadb 1.0.8.50358 Lifecycle binaries
PS C:\projects\cf-buildpack-template\lifecycle> cat .\version.json
{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "1.0",
  "pathFilters": [
    ".",
    ":!README.md"
  ],
  "publicReleaseRefSpec": [
    "^refs/heads/main$"
  ],
  "cloudBuild": {
    "buildNumber": {
      "enabled": true
    }
  },
  "inherit": false
}

@AArnott
Copy link
Collaborator

AArnott commented May 7, 2024

get-commits is the inverse of get-version. Where get-version provides the version for a given commit, get-commits provides the commit(s) that would build a given version. There may be more than one commit (and thus the plural name) because while a commit is perfectly precise, an a.b.c.d version is not and ambiguity may exist. When ambiguity exists because multiple commits might build the same a.b.c.d version, all are listed.

As to why you get 1.0.8, that's because in the commit before you added the nested version.json, that same directory built 1.0.7 (on account of the repo-root level version.json file setting 1.0 seven commits ago.)
NB.GV works hard to never let versioning go backwards. So if you were at 1.0.7 before, your next commit will be 1.0.8. The only (good) way to reset the git commit counter would be to actually increment the major or minor version specified in your version.json file.

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