Skip to content

Commit

Permalink
Bump version: 0.5.0 → 0.5.1
Browse files Browse the repository at this point in the history
fixed the issue where the pull command were not pulling the changes
to the branch
  • Loading branch information
arzkar committed Jul 5, 2023
1 parent 2e86174 commit 6a64c74
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .git-utils-bump.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.0
current_version = 0.5.1
commit = True
tag = False
tag_format = v{tag}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go install github.com/arzkar/git-utils@latest

```
> git-utils
git-utils v0.5.0
git-utils v0.5.1
Copyright (c) Arbaaz Laskar <[email protected]>
A CLI for performing various operations on git repositories
Expand Down
26 changes: 14 additions & 12 deletions cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func pullRepository(path string, pull string, dryRun bool) error {
} else {
branches := strings.Split(pull, ",")
for _, branch := range branches {
err := pullBranch(path, branch, dryRun)
localBranch := strings.TrimSpace(strings.TrimPrefix(branch, "origin/"))
err := pullBranch(path, localBranch, branch, dryRun)
if err != nil {
return err
}
Expand All @@ -122,7 +123,8 @@ func pullAllBranches(path string, dryRun bool) error {

branches := strings.Split(strings.TrimSpace(string(output)), "\n")
for _, branch := range branches {
err := pullBranch(path, branch, dryRun)
localBranch := strings.TrimSpace(strings.TrimPrefix(branch, "origin/"))
err := pullBranch(path, localBranch, branch, dryRun)
if err != nil {
return err
}
Expand All @@ -131,29 +133,29 @@ func pullAllBranches(path string, dryRun bool) error {
return nil
}

func pullBranch(path string, branch string, dryRun bool) error {
fmt.Printf("Pulling branch '%s' in repository '%s'\n", branch, path)
execDryRun(dryRun, path, branch)
func pullBranch(path string, localBranch string, remoteBranch string, dryRun bool) error {
fmt.Printf("Pulling branch '%s' in repository '%s'\n", localBranch, path)
execDryRun(dryRun, path, localBranch)

// Show the changes made by the pull operation
cmd := exec.Command("git", "-C", path, "diff", "--stat", branch+"..origin/"+branch)
cmd := exec.Command("git", "-C", path, "diff", "--stat", localBranch+"..origin/"+remoteBranch)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to get changes made by pull for branch '%s' in repository '%s': %w\n%s", branch, path, err, string(output))
return fmt.Errorf("failed to get changes made by pull for branch '%s' in repository '%s': %w\n%s", localBranch, path, err, string(output))
}

if len(output) > 0 {
fmt.Println("Changes made by pull:")
fmt.Println("Diff: " + localBranch + "..origin/" + remoteBranch)
colorizedOutput := utils.ColorizeDiffStat(string(output))
fmt.Println(colorizedOutput)

cmd = exec.Command("git", "-C", path, "pull")
cmd = exec.Command("git", "-C", path, "pull", "origin", remoteBranch+":"+localBranch)
output, err = cmd.CombinedOutput()
// println(string(output))
if err != nil {
return fmt.Errorf("failed to pull branch '%s' in repository '%s': %w\n%s", branch, path, err, string(output))
return fmt.Errorf("failed to pull branch '%s' in repository '%s': %w\n%s", localBranch, path, err, string(output))
}

fmt.Printf(color.GreenString("Successfully pulled branch '%s' in repository '%s'\n\n", branch, path))
fmt.Printf(color.GreenString("Successfully pulled branch '%s' in repository '%s'\n\n", localBranch, path))
} else {
fmt.Println(color.GreenString("No changes made by pull\n"))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
var rootCmd = &cobra.Command{
Use: "git-utils",
Short: "A CLI for performing various operations on git repositories",
Long: `git-utils v0.5.0
Long: `git-utils v0.5.1
Copyright (c) Arbaaz Laskar <[email protected]>
A CLI for performing various operations on git repositories
Expand Down
2 changes: 1 addition & 1 deletion utils/update_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
repoOwner = "arzkar"
repoName = "git-utils"
releasesAPI = "https://api.github.com/repos/%s/%s/releases/latest"
currentVersion = "v0.5.0"
currentVersion = "v0.5.1"
configFile = "config.json"
updateInterval = 24 * time.Hour
)
Expand Down

0 comments on commit 6a64c74

Please sign in to comment.