Unverified Commit 24fa2986 authored by kirillrdy's avatar kirillrdy Committed by GitHub
Browse files

Merge pull request #290084 from bryanhonof/bryanhonof.flottbot-init

flottbot: init at 0.13.0
parents 4c7ba006 8fcb4589
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
{ lib
, buildGoModule
, fetchFromGitHub
, nix-update-script
, substituteAll
}:
buildGoModule rec {
  pname = "flottbot";
  version = "0.13.0";

  src = fetchFromGitHub {
    owner = "target";
    repo = "flottbot";
    rev = version;
    hash = "sha256-ldWE5QcLHyIqap5Qe6OTTIJZ1sshI+CVoJoRUxWHfxM=";
  };

  patches = [
    # patch out debug.ReadBuidlInfo since version information is not available with buildGoModule
    (substituteAll {
      src = ./version.patch;
      version = version;
      vcsHash = version; # Maybe there is a way to get the git ref from src? idk.
    })
  ];

  vendorHash = "sha256-XRcTp3ZnoPupzI1kjoM4oF5+VlNJFV0Bu+WAwfRWl7g=";

  subPackages = [ "cmd/flottbot" ];

  passthru = {
    updateScript = nix-update-script { };
  };

  meta = with lib; {
    description = "A chatbot framework written in Go";
    homepage = "https://github.com/target/flottbot";
    license = licenses.asl20;
    maintainers = with maintainers; [ bryanhonof ];
    sourceProvenance = [ sourceTypes.fromSource ];
    mainProgram = "flottbot";
    platforms = platforms.unix;
  };
}
+37 −0
Original line number Diff line number Diff line
diff --git a/version/version.go b/version/version.go
index 9ca8aba..d9bd968 100644
--- a/version/version.go
+++ b/version/version.go
@@ -4,9 +4,6 @@ package version
 
 import (
 	"fmt"
-	"runtime/debug"
-
-	"github.com/Masterminds/semver/v3"
 )
 
 // Version supplies the semantic version.
@@ -14,20 +11,8 @@ var Version string
 
 // String prints the build information for the bot.
 func String() string {
-	hash := "unknown"
-
-	_, err := semver.NewVersion(Version)
-	if err != nil {
-		Version = "dev"
-	}
-
-	if info, ok := debug.ReadBuildInfo(); ok {
-		for _, s := range info.Settings {
-			if s.Key == "vcs.revision" {
-				hash = s.Value
-			}
-		}
-	}
+	Version = "@version@"
+	hash := "@vcsHash@"
 
 	return fmt.Sprintf("Version : %s\nGit Hash: %s\n", Version, hash)
 }