From 6b3320ef9c5f21f8961686c4acb24678f1552685 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 4 Nov 2025 22:15:15 -0500 Subject: refactor: clean up gitignore comments and update repository url configuration --- .gitignore | 22 +--------------------- internal/utils/version.go | 7 +++++-- internal/utils/version_test.go | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 773e012..bd4904e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,15 @@ -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins *.exe *.exe~ *.dll *.so *.dylib - -# Test binary, built with `go test -c` *.test - -# Code coverage profiles and other test artifacts *.out coverage.* *.coverprofile profile.cov - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file go.work go.work.sum - -# env file .env - -# Editor/IDE -# .idea/ -# .vscode/ - -dborg +dborg* doc.json diff --git a/internal/utils/version.go b/internal/utils/version.go index 950f6fa..1759ecc 100644 --- a/internal/utils/version.go +++ b/internal/utils/version.go @@ -10,7 +10,10 @@ import ( "github.com/spf13/cobra" ) -var Version = "dev" +var ( + Version = "dev" + RepositoryURL = "git@45.38.20.139:repos/dborg.git" +) func CheckForUpdates(cmd *cobra.Command) error { if !isTerminal() { @@ -34,7 +37,7 @@ func CheckForUpdates(cmd *cobra.Command) error { } func getLatestRemoteTag() (string, error) { - cmd := exec.Command("git", "ls-remote", "--tags", "--refs", "--sort=-v:refname", "git.db.org.ai/dborg") + cmd := exec.Command("git", "ls-remote", "--tags", "--refs", "--sort=-v:refname", RepositoryURL) output, err := cmd.Output() if err != nil { return "", err diff --git a/internal/utils/version_test.go b/internal/utils/version_test.go index dc1627d..aef3645 100644 --- a/internal/utils/version_test.go +++ b/internal/utils/version_test.go @@ -1,6 +1,9 @@ package utils -import "testing" +import ( + "strings" + "testing" +) func TestIsNewerVersion(t *testing.T) { tests := []struct { @@ -50,3 +53,21 @@ func TestIsNewerVersion(t *testing.T) { }) } } + +func TestGetLatestRemoteTag(t *testing.T) { + tag, err := getLatestRemoteTag() + if err != nil { + t.Skipf("Skipping test: unable to fetch remote tags: %v", err) + return + } + + if tag == "" { + t.Error("Expected non-empty tag, got empty string") + } + + if !strings.HasPrefix(tag, "v") { + t.Errorf("Expected tag to start with 'v', got: %s", tag) + } + + t.Logf("Latest remote tag: %s", tag) +} -- cgit v1.2.3