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

Nerdbank.GitVersioning segment / support #777

Closed
devhawk opened this issue Jun 3, 2021 · 6 comments · Fixed by #780
Closed

Nerdbank.GitVersioning segment / support #777

devhawk opened this issue Jun 3, 2021 · 6 comments · Fixed by #780
Labels
🚀 feat New feature

Comments

@devhawk
Copy link

devhawk commented Jun 3, 2021

it would be awesome if the git segment supported Nerdbank.GitVersioning. Or if there nbgv had its own segment.

I looked at doing this manually with the Command segment, but the segment would need a mechanism to handle "not a git repo" and "is a git repo but isn't configured for Nerdbank.GitVersioning" scenarios.

@JanDeDobbeleer JanDeDobbeleer added the 🚀 feat New feature label Jun 3, 2021
@JanDeDobbeleer
Copy link
Owner

@devhawk creating a segment isn't tricky, but you'll need to guide me into what you'd like to see. For example, which command output to run, when to run etc...

@devhawk
Copy link
Author

devhawk commented Jun 3, 2021

I don't know the code base and frankly I'm not proficient in Go, so I have no idea what is feasible or not. But since you asked, here's what I'd like to see:

  • Hide the segment if we aren't in a git directory (i.e. like the behavior of the git segment)
  • Hide the segment if we are in a git directory but the VersionFileFound property of nbgv get-version --format json results is false
  • Show the segment with a configurable choice of version display options if the VersionFileFound property is true

Suggested version display options (from properties returned by nbgv get-version --format json)

  • Version: 2.0.35.62141
  • AssemblyVersion: 2.0.0.0
  • AssemblyInformationalVersion: 2.0.35-preview+bdf2320560
  • NuGetPackageVersion: 2.0.35-preview
  • NpmPackageVersion: 2.0.35-preview
  • SimpleVersion: 2.0.35

Personally, I only care about the nuget package version, but other folks might want to display one of the other properties

example nbgv get-version --format json for a git repo configured for nerdbank gitversion

{
    "CloudBuildNumber": "2.0.35-preview",
    "CloudBuildNumberEnabled": true,
    "BuildMetadataWithCommitId": [
        "bdf2320560"
    ],
    "VersionFileFound": true,
    "VersionOptions": {
        "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
        "Version": {
            "Version": "2.0",
            "Prerelease": "-preview",
            "BuildMetadata": ""
        },
        "PublicReleaseRefSpec": [
            "^refs/heads/master$",
            "^refs/heads/master-2.x$",
            "^refs/heads/release/v\\d+(?:\\.\\d+)?$"
        ],
        "CloudBuild": {
            "SetAllVariables": null,
            "SetVersionVariables": null,
            "BuildNumber": {
                "Enabled": true,
                "IncludeCommitId": null
            }
        },
        "Release": {
            "BranchName": "release/v{version}",
            "FirstUnstableTag": "preview"
        }
    },
    "AssemblyVersion": "2.0.0.0",
    "AssemblyFileVersion": "2.0.35.62141",
    "AssemblyInformationalVersion": "2.0.35-preview+bdf2320560",
    "PublicRelease": true,
    "PrereleaseVersion": "-preview",
    "PrereleaseVersionNoLeadingHyphen": "preview",
    "SimpleVersion": "2.0.35",
    "BuildNumber": 35,
    "VersionRevision": 62141,
    "MajorMinorVersion": "2.0",
    "VersionMajor": 2,
    "VersionMinor": 0,
    "GitCommitId": "bdf232056019c3d99927702963979f5026cf4237",
    "GitCommitIdShort": "bdf2320560",
    "GitCommitDate": "2021-06-02T21:48:28+00:00",
    "VersionHeight": 35,
    "VersionHeightOffset": 0,
    "BuildingRef": "refs/heads/master",
    "Version": "2.0.35.62141",
    "CloudBuildAllVarsEnabled": false,
    "CloudBuildAllVars": {
        "NBGV_CloudBuildNumber": "2.0.35-preview",
        "NBGV_VersionFileFound": "True",
        "NBGV_VersionOptions": "Nerdbank.GitVersioning.VersionOptions",
        "NBGV_AssemblyVersion": "2.0.0.0",
        "NBGV_AssemblyFileVersion": "2.0.35.62141",
        "NBGV_AssemblyInformationalVersion": "2.0.35-preview+bdf2320560",
        "NBGV_PublicRelease": "True",
        "NBGV_PrereleaseVersion": "-preview",
        "NBGV_PrereleaseVersionNoLeadingHyphen": "preview",
        "NBGV_SimpleVersion": "2.0.35",
        "NBGV_BuildNumber": "35",
        "NBGV_VersionRevision": "62141",
        "NBGV_MajorMinorVersion": "2.0",
        "NBGV_VersionMajor": "2",
        "NBGV_VersionMinor": "0",
        "NBGV_GitCommitId": "bdf232056019c3d99927702963979f5026cf4237",
        "NBGV_GitCommitIdShort": "bdf2320560",
        "NBGV_GitCommitDate": "6/2/2021 9:48:28 PM +00:00",
        "NBGV_VersionHeight": "35",
        "NBGV_VersionHeightOffset": "0",
        "NBGV_BuildingRef": "refs/heads/master",
        "NBGV_Version": "2.0.35.62141",
        "NBGV_BuildMetadataFragment": "+bdf2320560",
        "NBGV_NuGetPackageVersion": "2.0.35-preview",
        "NBGV_ChocolateyPackageVersion": "2.0.35-preview",
        "NBGV_NpmPackageVersion": "2.0.35-preview",
        "NBGV_SemVer1": "2.0.35-preview",
        "NBGV_SemVer2": "2.0.35-preview",
        "NBGV_SemVer1NumericIdentifierPadding": "4"
    },
    "CloudBuildVersionVarsEnabled": true,
    "CloudBuildVersionVars": {
        "GitAssemblyInformationalVersion": "2.0.35-preview+bdf2320560",
        "GitBuildVersion": "2.0.35.62141",
        "GitBuildVersionSimple": "2.0.35"
    },
    "BuildMetadata": [],
    "BuildMetadataFragment": "+bdf2320560",
    "NuGetPackageVersion": "2.0.35-preview",
    "ChocolateyPackageVersion": "2.0.35-preview",
    "NpmPackageVersion": "2.0.35-preview",
    "SemVer1": "2.0.35-preview",
    "SemVer2": "2.0.35-preview",
    "SemVer1NumericIdentifierPadding": 4
}

example nbgv get-version --format json for a git repo NOT configured for nerdbank gitversion

{
  "CloudBuildNumber": "0.0.0+be5538c1e7",
  "CloudBuildNumberEnabled": false,
  "BuildMetadataWithCommitId": [
    "be5538c1e7"
  ],
  "VersionFileFound": false,
  "VersionOptions": null,
  "AssemblyVersion": "0.0.0.0",
  "AssemblyFileVersion": "0.0.0.21950",
  "AssemblyInformationalVersion": "0.0.0+be5538c1e7",
  "PublicRelease": false,
  "PrereleaseVersion": "",
  "PrereleaseVersionNoLeadingHyphen": "",
  "SimpleVersion": "0.0.0",
  "BuildNumber": 0,
  "VersionRevision": 21950,
  "MajorMinorVersion": "0.0",
  "VersionMajor": 0,
  "VersionMinor": 0,
  "GitCommitId": "be5538c1e7924cc2a3c745f13eb5dc08a0789ef0",
  "GitCommitIdShort": "be5538c1e7",
  "GitCommitDate": "2021-04-13T06:11:47+00:00",
  "VersionHeight": 0,
  "VersionHeightOffset": 0,
  "BuildingRef": "refs/heads/master",
  "Version": "0.0.0.21950",
  "CloudBuildAllVarsEnabled": false,
  "CloudBuildAllVars": {
    "NBGV_CloudBuildNumber": "0.0.0+be5538c1e7",
    "NBGV_VersionFileFound": "False",
    "NBGV_AssemblyVersion": "0.0.0.0",
    "NBGV_AssemblyFileVersion": "0.0.0.21950",
    "NBGV_AssemblyInformationalVersion": "0.0.0+be5538c1e7",
    "NBGV_PublicRelease": "False",
    "NBGV_PrereleaseVersion": "",
    "NBGV_PrereleaseVersionNoLeadingHyphen": "",
    "NBGV_SimpleVersion": "0.0.0",
    "NBGV_BuildNumber": "0",
    "NBGV_VersionRevision": "21950",
    "NBGV_MajorMinorVersion": "0.0",
    "NBGV_VersionMajor": "0",
    "NBGV_VersionMinor": "0",
    "NBGV_GitCommitId": "be5538c1e7924cc2a3c745f13eb5dc08a0789ef0",
    "NBGV_GitCommitIdShort": "be5538c1e7",
    "NBGV_GitCommitDate": "4/13/2021 6:11:47 AM +00:00",
    "NBGV_VersionHeight": "0",
    "NBGV_VersionHeightOffset": "0",
    "NBGV_BuildingRef": "refs/heads/master",
    "NBGV_Version": "0.0.0.21950",
    "NBGV_BuildMetadataFragment": "+be5538c1e7",
    "NBGV_NuGetPackageVersion": "0.0.0-gbe5538c1e7",
    "NBGV_ChocolateyPackageVersion": "0.0.0-gbe5538c1e7",
    "NBGV_NpmPackageVersion": "0.0.0-gbe5538c1e7",
    "NBGV_SemVer1": "0.0.0-be5538c1e7",
    "NBGV_SemVer2": "0.0.0-gbe5538c1e7",
    "NBGV_SemVer1NumericIdentifierPadding": "4"
  },
  "CloudBuildVersionVarsEnabled": true,
  "CloudBuildVersionVars": {
    "GitAssemblyInformationalVersion": "0.0.0+be5538c1e7",
    "GitBuildVersion": "0.0.0.21950",
    "GitBuildVersionSimple": "0.0.0"
  },
  "BuildMetadata": [],
  "BuildMetadataFragment": "+be5538c1e7",
  "NuGetPackageVersion": "0.0.0-gbe5538c1e7",
  "ChocolateyPackageVersion": "0.0.0-gbe5538c1e7",
  "NpmPackageVersion": "0.0.0-gbe5538c1e7",
  "SemVer1": "0.0.0-be5538c1e7",
  "SemVer2": "0.0.0-gbe5538c1e7",
  "SemVer1NumericIdentifierPadding": 4
}

@JanDeDobbeleer
Copy link
Owner

@devhawk I was referring to myself when I stated that 😅. This info should work! Let me find some time.

@devhawk
Copy link
Author

devhawk commented Jun 3, 2021

@devhawk I was referring to myself when I stated that 😅. This info should work! Let me find some time.

I hoped/figured. Just trying to be the dev asking for someone to implement my pet feature in a "gentle and well-educated manner"

JanDeDobbeleer added a commit that referenced this issue Jun 4, 2021
@JanDeDobbeleer JanDeDobbeleer mentioned this issue Jun 4, 2021
4 tasks
JanDeDobbeleer added a commit that referenced this issue Jun 4, 2021
JanDeDobbeleer added a commit that referenced this issue Jun 5, 2021
@JanDeDobbeleer
Copy link
Owner

@devhawk I did notice the response time from nbgv are rather slow (300/400ms which impacts the responsiveness). I'll add that information to the docs.

JanDeDobbeleer added a commit that referenced this issue Jun 5, 2021
JanDeDobbeleer added a commit that referenced this issue Jun 5, 2021
JanDeDobbeleer added a commit that referenced this issue Jun 5, 2021
Copy link

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues.
If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🚀 feat New feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants