Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
99b0055
perf: removed the Go Report badge from the readme
ChanduBobbili Aug 28, 2026
031c066
feat: add configuration support for changeset management
ChanduBobbili Sep 3, 2026
b807ba4
refactor: clean up code formatting and remove unused constant
ChanduBobbili Sep 3, 2026
baf37f4
feat: enhance configuration structure for changelog and commit settings
ChanduBobbili Sep 4, 2026
954daed
perf: added changeset for release update
ChanduBobbili Sep 4, 2026
a3b5c45
Merge branch 'main' into feat/configuration-file
ChanduBobbili Sep 4, 2026
6c021af
perf: updated the changeset bump type
ChanduBobbili Sep 4, 2026
2e082e4
feat: implement changeset validation and status check functionality
ChanduBobbili Sep 4, 2026
ff081ab
perf: added the changeset for release update
ChanduBobbili Sep 4, 2026
26f0120
Merge branch 'feat/configuration-file' into feat/changed-file-patterns
ChanduBobbili Sep 4, 2026
0c18d29
feat: setting up the git utils
ChanduBobbili Sep 7, 2026
2f74bff
Merge branch 'main' into feat/changed-file-patterns
ChanduBobbili Sep 7, 2026
d01b2cb
feat: refactor git operations to use GitRepository methods and improv…
ChanduBobbili Sep 7, 2026
a876206
feat: integrate git repository methods into changeset handling
ChanduBobbili Sep 7, 2026
a7662d5
feat: refactor changeset handling to utilize GitRepository methods an…
ChanduBobbili Sep 7, 2026
bad3c0e
perf: added the changesets for release update
ChanduBobbili Sep 7, 2026
6dd94d0
feat: enhance release confirmation with interactive prompt
ChanduBobbili Sep 7, 2026
b07e158
perf: removed unwanted changeset
ChanduBobbili Sep 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changesets/major-1788790888874863721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Introduced `changedFilePattern` to allow filtering of changed files against user-defined patterns, ensuring version bumps are only triggered by relevant file modifications.
1 change: 1 addition & 0 deletions .changesets/minor-1788790839776692553.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrated internal Git operations from `os/exec` shell commands to the `go-git` library to make the CLI fully self-contained and cross-platform compatible.
2 changes: 1 addition & 1 deletion .changesets/patch-1788520819013459586.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Migrate description input to chzyer/readline to fix multi-print pasting bugs, add interrupt handling for clean exits, and resolve filepath variable shadowing.
Migrate description input to `chzyer/readline` to fix multi-print pasting bugs, add interrupt handling for clean exits, and resolve filepath variable shadowing.
10 changes: 8 additions & 2 deletions changeset/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ func ApplyChangesets(cfg config.Config) (string, error) {

bumpType := determineBumpType(majors, minors, patches)

current, _ := GetLatestVersion()
newVersion, _ := BumpVersion(current, bumpType)
current, err := GetLatestVersion()
if err != nil {
return "", err
}
newVersion, err := BumpVersion(current, bumpType)
if err != nil {
return "", err
}

if cfg.Changelog.Enabled {
if err := updateChangelog(newVersion, majors, minors, patches, cfg); err != nil {
Expand Down
11 changes: 10 additions & 1 deletion changeset/changeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/ChanduBobbili/changesetgoo/config"
"github.com/ChanduBobbili/changesetgoo/enums"
"github.com/ChanduBobbili/changesetgoo/utils/git"
"github.com/chzyer/readline"
"github.com/manifoldco/promptui"
)
Expand Down Expand Up @@ -49,7 +50,15 @@ func AddChangeset(releaseType enums.ReleaseType, message string, cfg config.Conf
}

// InteractiveAdd allows user to input bump type and description
func InteractiveAdd(cfg config.Config) error {
func InteractiveAdd(gitRepo *git.GitRepository, cfg config.Config) error {
hasChanges, err := HasChangesForChangeset(gitRepo, cfg)
if err != nil {
return err
}
if !hasChanges {
return fmt.Errorf("no changes detected; nothing to add a changeset for")
}

bump, err := PromptReleaseType()
if err != nil {
return err
Expand Down
155 changes: 155 additions & 0 deletions changeset/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package changeset

import (
"fmt"
"os"
"regexp"
"strings"

"github.com/ChanduBobbili/changesetgoo/config"
"github.com/ChanduBobbili/changesetgoo/utils/git"
)

// GetChangedFiles returns the files changed between a ref and HEAD.
func GetChangedFiles(gitRepo *git.GitRepository, ref string) ([]string, error) {
return gitRepo.DiffTreesFromRefs(ref, "HEAD")
}

func ResolveChangeRef(gitRepo *git.GitRepository, cfg config.Config) (string, error) {
branch, err := gitRepo.GetCurrentBranch()
if err != nil {
return "", err
}

if branch != cfg.BaseBranch {
return cfg.BaseBranch, nil
}

version, err := GetLatestVersion()
if err != nil {
return "", err
}
tag := cfg.TagPrefix + version

exists, err := gitRepo.CheckTagExists(tag)
if err != nil {
return "", fmt.Errorf("failed to check tag %s: %w", tag, err)
}
if exists {
return tag, nil
}

rootCommit, err := gitRepo.GetRootCommit()
if err != nil {
return "", fmt.Errorf("no tag %s found and failed to resolve root commit: %w", tag, err)
}
return rootCommit, nil
}

func HasChangesForChangeset(gitRepo *git.GitRepository, cfg config.Config) (bool, error) {
ref, err := ResolveChangeRef(gitRepo, cfg)
if err != nil {
return false, err
}
return gitRepo.HasChangesSinceRef(ref)
}

// GetRelevantChangedFiles returns changed files matching ChangedFilePatterns.
func GetRelevantChangedFiles(gitRepo *git.GitRepository, cfg config.Config) ([]string, error) {
ref, err := ResolveChangeRef(gitRepo, cfg)
if err != nil {
return nil, err
}

files, err := GetChangedFiles(gitRepo, ref)
if err != nil {
return nil, err
}

relevant := make([]string, 0)
for _, file := range files {
if MatchesAnyPattern(file, cfg.ChangedFilePatterns) {
relevant = append(relevant, file)
}
}

return relevant, nil
}

// MatchesAnyPattern reports whether a file matches at least one pattern.
func MatchesAnyPattern(file string, patterns []string) bool {
for _, pattern := range patterns {
if globToRegexp(pattern).MatchString(file) {
return true
}
}
return false
}

func globToRegexp(pattern string) *regexp.Regexp {
var b strings.Builder
b.WriteString("^")

for i := 0; i < len(pattern); {
switch {
case strings.HasPrefix(pattern[i:], "**"):
b.WriteString(".*")
i += 2
case pattern[i] == '*':
b.WriteString("[^/]*")
i++
case pattern[i] == '?':
b.WriteString(".")
i++
default:
b.WriteString(regexp.QuoteMeta(string(pattern[i])))
i++
}
}

b.WriteString("$")
return regexp.MustCompile(b.String())
}

// HasPendingChangesets reports whether there are any pending .md changesets.
func HasPendingChangesets(changesDir string) (bool, error) {
entries, err := os.ReadDir(changesDir)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

for _, entry := range entries {
if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".md") {
return true, nil
}
}

return false, nil
}

// CheckChangesetRequirement enforces changedFilePatterns semantics for CI-style
// checks. It returns whether the check passes and the relevant matched files.
func CheckChangesetRequirement(gitRepo *git.GitRepository, cfg config.Config) (bool, []string, error) {
relevantFiles, err := GetRelevantChangedFiles(gitRepo, cfg)
if err != nil {
return false, nil, err
}

if len(relevantFiles) == 0 {
return true, relevantFiles, nil
}

hasPending, err := HasPendingChangesets(cfg.ChangesDir)
if err != nil {
return false, nil, err
}

if hasPending {
return true, relevantFiles, nil
}

return false, relevantFiles, nil
}
Loading
Loading