Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ If neither source provides a token, requests are made without authentication.

## GOPROXY

When `goproxy` is set, **gogitup** passes the configured value as the `GOPROXY` environment variable when running `go install` (during both `install` and `update`). This is useful in environments that require a custom module proxy.
When `goproxy` is set, **gogitup** passes the configured value as the `GOPROXY` environment variable when running `go install` (during both `install` and `upgrade`). This is useful in environments that require a custom module proxy.

{: .note }
If `goproxy` is not set or is empty, the `GOPROXY` value is inherited from the current process environment (the default Go behavior).

## CGO_ENABLED

When `cgo_enabled` is set, **gogitup** passes the configured value as the `CGO_ENABLED` environment variable when running `go install` (during both `install` and `update`). Setting `cgo_enabled: false` disables cgo for all installs and updates, which is useful in environments where cgo is unavailable or undesirable.
When `cgo_enabled` is set, **gogitup** passes the configured value as the `CGO_ENABLED` environment variable when running `go install` (during both `install` and `upgrade`). Setting `cgo_enabled: false` disables cgo for all installs and updates, which is useful in environments where cgo is unavailable or undesirable.

{: .note }
If `cgo_enabled` is not set, the `CGO_ENABLED` value is inherited from the current process environment (the default Go behavior).
Expand All @@ -70,7 +70,7 @@ If `cgo_enabled` is not set, the `CGO_ENABLED` value is inherited from the curre
The cache file is located at `~/.gogitup.cache` and uses YAML format. It stores the latest version information retrieved from GitHub so that repeated checks do not require additional API calls.

{: .important }
Cache entries expire after **24 hours**. After expiry the next `check` or `update` will re-fetch the latest release from GitHub. A check can be forced with `--force` to bypass the cache, but the purpose of the cache is to avoid unnecessary API calls to GitHub.
Cache entries expire after **24 hours**. After expiry the next `check` or `upgrade` will re-fetch the latest release from GitHub. A check can be forced with `--force` to bypass the cache, but the purpose of the cache is to avoid unnecessary API calls to GitHub.

### Example

Expand Down
14 changes: 7 additions & 7 deletions docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ Update Check
{: .important }
The `check` command only checks for updates once every 24 hours caching the latest release information. Use `gogitup check --force` to bypass the cache and re-fetch from GitHub.

## Updating All Tools
## Upgrading All Tools

Run a single command to update every tracked binary that has a newer release:
Run a single command to upgrade every tracked binary that has a newer release:

```bash
gogitup update
gogitup upgrade
```

```
gogitup update --verbose
Updating 'bulkfilepr' from v0.2.2 to v0.2.3...
Updated 'bulkfilepr' to v0.2.3
gogitup upgrade --verbose
Upgrading 'bulkfilepr' from v0.2.2 to v0.2.3...
Upgraded 'bulkfilepr' to v0.2.3
ℹ 'ghorgsync' is already up to date (v0.1.0)

Updated 1 binary(ies).
Upgraded 1 binary(ies).
```

## Using JSON Output for Scripting
Expand Down
8 changes: 4 additions & 4 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cd gogitup
go build -o gogitup
```

## Updating with gogitup
## Upgrading with gogitup

### Registering with gogitup

Expand All @@ -56,10 +56,10 @@ Tell **gogitup** that it should manage the updates for **gogitup**:
gogitup add gogitup
```

### Updating with gogitup
### Upgrading with gogitup

Update the registered packages using **gogitup**:
Upgrade the registered packages using **gogitup**:

```bash
gogitup update
gogitup upgrade
```
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ gogitup add gogitup
# Check for updates
gogitup check

# Update all tracked tools
gogitup update
# Upgrade all tracked tools
gogitup upgrade
```
14 changes: 7 additions & 7 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ gogitup install <owner/repo>
1. Fetches the latest release tag for the repository from the GitHub Releases API.
2. Runs `go install github.com/<owner>/<repo>@<latest>`.
3. Verifies that the resulting binary (named after the repository) is available on `PATH`.
4. Registers the binary with **gogitup** for future `check` and `update` tracking.
4. Registers the binary with **gogitup** for future `check` and `upgrade` tracking.

If the installed binary name differs from the repository name (uncommon), the installation itself still succeeds but the binary will not be registered automatically. Use `gogitup add <name>` to register it manually.

---

## `remove`

Removes a binary from tracking. The binary itself is not uninstalled, **gogitup** just stops tracking it for updates when you run `check` or `update`.
Removes a binary from tracking. The binary itself is not uninstalled, **gogitup** just stops tracking it for updates when you run `check` or `upgrade`.

```bash
gogitup remove <name>
Expand Down Expand Up @@ -125,18 +125,18 @@ By default, `check` uses a non-expired cache entry to reduce GitHub API calls. U

---

## `update`
## `upgrade`

Checks for updates and runs `go install` to update every registered binary that has a newer release available.
Checks for updates and runs `go install` to upgrade every registered binary that has a newer release available.

```bash
gogitup update
gogitup upgrade
```

| Name | Required | Default | Description |
|------|----------|---------|-------------|
| `--verbose` | No | `false` | Show binaries that are already up to date while checking for updates |

**What `update` does:**
**What `upgrade` does:**

`update` uses installed binary metadata (`go version -m -json`) plus the GitHub Releases API to find the latest release, then runs `go install <module>@<tag>` when an update is available. It refreshes the cache with the latest fetched tag and always fetches fresh release data (it does not rely on cached latest-version values).
`upgrade` uses installed binary metadata (`go version -m -json`) plus the GitHub Releases API to find the latest release, then runs `go install <module>@<tag>` when an update is available. It refreshes the cache with the latest fetched tag and always fetches fresh release data (it does not rely on cached latest-version values).
6 changes: 3 additions & 3 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func Execute(version string) {
runList(os.Args[2:])
case "check":
runCheck(os.Args[2:])
case "update":
runUpdate(os.Args[2:])
case "upgrade":
runUpgrade(os.Args[2:])
case "--help", "-h", "help":
printHelp()
default:
Expand All @@ -53,7 +53,7 @@ func printHelp() {
fmt.Printf(" %sremove%s <name> Remove a registered binary\n", output.Cyan, output.Reset)
fmt.Printf(" %slist%s List registered binaries and installed versions\n", output.Cyan, output.Reset)
fmt.Printf(" %scheck%s Check for available updates\n", output.Cyan, output.Reset)
fmt.Printf(" %supdate%s Update all binaries with available updates\n", output.Cyan, output.Reset)
fmt.Printf(" %supgrade%s Upgrade all binaries with available updates\n", output.Cyan, output.Reset)
fmt.Println()
fmt.Printf(" %sFlags:%s\n", output.Bold, output.Reset)
fmt.Printf(" %s--version, -v%s Print version\n", output.Cyan, output.Reset)
Expand Down
42 changes: 21 additions & 21 deletions internal/cmd/update.go → internal/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ import (
"github.com/UnitVectorY-Labs/gogitup/internal/output"
)

type updateOptions struct {
type upgradeOptions struct {
Verbose bool
}

type updateDependencies struct {
type upgradeDependencies struct {
runner goversion.Runner
ghClient github.Client
installer installer.Installer
out *output.Writer
errOut *output.Writer
}

func parseUpdateOptions(args []string, stderr io.Writer) (updateOptions, error) {
fs := flag.NewFlagSet("update", flag.ContinueOnError)
func parseUpgradeOptions(args []string, stderr io.Writer) (upgradeOptions, error) {
fs := flag.NewFlagSet("upgrade", flag.ContinueOnError)
fs.SetOutput(stderr)

verboseFlag := fs.Bool("verbose", false, "Show binaries that are already up to date")
if err := fs.Parse(args); err != nil {
return updateOptions{}, err
return upgradeOptions{}, err
}

return updateOptions{Verbose: *verboseFlag}, nil
return upgradeOptions{Verbose: *verboseFlag}, nil
}

func runUpdate(args []string) {
opts, err := parseUpdateOptions(args, output.ErrorWriter.Out)
func runUpgrade(args []string) {
opts, err := parseUpgradeOptions(args, output.ErrorWriter.Out)
if err != nil {
if errors.Is(err, flag.ErrHelp) {
return
Expand Down Expand Up @@ -70,14 +70,14 @@ func runUpdate(args []string) {
runner := &goversion.DefaultRunner{}
ghClient := github.NewDefaultClient(github.ResolveToken(cfg.GitHubAuth))
inst := installer.NewDefaultInstallerWithOptions(cfg.GOPROXY, cfg.CGOEnabled)
deps := updateDependencies{
deps := upgradeDependencies{
runner: runner,
ghClient: ghClient,
installer: inst,
out: output.DefaultWriter,
errOut: output.ErrorWriter,
}
updated := runUpdateApps(cfg, c, opts, deps)
updated := runUpgradeApps(cfg, c, opts, deps)

// Save updated cache
_ = cache.Save(cachePath, c)
Expand All @@ -86,11 +86,11 @@ func runUpdate(args []string) {
if updated == 0 {
deps.out.Info("All binaries are up to date.")
} else {
deps.out.Success(fmt.Sprintf("Updated %d binary(ies).", updated))
deps.out.Success(fmt.Sprintf("Upgraded %d binary(ies).", updated))
}
}

func runUpdateApps(cfg *config.Config, c *cache.Cache, opts updateOptions, deps updateDependencies) int {
func runUpgradeApps(cfg *config.Config, c *cache.Cache, opts upgradeOptions, deps upgradeDependencies) int {
updated := 0

for _, app := range cfg.Apps {
Expand All @@ -117,36 +117,36 @@ func runUpdateApps(cfg *config.Config, c *cache.Cache, opts updateOptions, deps

if info.Version == latest {
if opts.Verbose {
deps.out.Info(updateUpToDateMessage(app.Name, info.Version))
deps.out.Info(upgradeUpToDateMessage(app.Name, info.Version))
}
continue
}

deps.out.StartProgress(updateProgressMessage(app.Name, info.Version, latest))
deps.out.StartProgress(upgradeProgressMessage(app.Name, info.Version, latest))

_, err = deps.installer.Install(info.Path, latest)
if err != nil {
deps.errOut.Error(fmt.Sprintf("Failed to update '%s': %v", app.Name, err))
deps.errOut.Error(fmt.Sprintf("Failed to upgrade '%s': %v", app.Name, err))
continue
}

deps.out.Success(updateSuccessMessage(app.Name, latest))
deps.out.Success(upgradeSuccessMessage(app.Name, latest))
updated++
}

return updated
}

func updateUpToDateMessage(name, version string) string {
func upgradeUpToDateMessage(name, version string) string {
return fmt.Sprintf("'%s' is already up to date (%s)", name, installedVersion(version))
}

func updateProgressMessage(name, currentVersion, latestVersion string) string {
return fmt.Sprintf("Updating '%s' from %s to %s", name, installedVersion(currentVersion), latestVersionLabel(latestVersion))
func upgradeProgressMessage(name, currentVersion, latestVersion string) string {
return fmt.Sprintf("Upgrading '%s' from %s to %s", name, installedVersion(currentVersion), latestVersionLabel(latestVersion))
}

func updateSuccessMessage(name, version string) string {
return fmt.Sprintf("Updated '%s' to %s", name, installedVersion(version))
func upgradeSuccessMessage(name, version string) string {
return fmt.Sprintf("Upgraded '%s' to %s", name, installedVersion(version))
}

func installedVersion(version string) string {
Expand Down
18 changes: 9 additions & 9 deletions internal/cmd/update_test.go → internal/cmd/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ func (s *stubInstaller) Install(modulePath, version string) (string, error) {
return "ok", nil
}

func TestParseUpdateOptionsVerbose(t *testing.T) {
func TestParseUpgradeOptionsVerbose(t *testing.T) {
var stderr bytes.Buffer

opts, err := parseUpdateOptions([]string{"--verbose"}, &stderr)
opts, err := parseUpgradeOptions([]string{"--verbose"}, &stderr)
if err != nil {
t.Fatalf("parseUpdateOptions returned error: %v", err)
t.Fatalf("parseUpgradeOptions returned error: %v", err)
}

if !opts.Verbose {
t.Fatalf("expected verbose option to be enabled")
}
}

func TestRunUpdateAppsSuppressesUpToDateEntriesByDefault(t *testing.T) {
func TestRunUpgradeAppsSuppressesUpToDateEntriesByDefault(t *testing.T) {
cfg := &config.Config{
Apps: []config.App{
{Name: "current"},
Expand All @@ -104,7 +104,7 @@ func TestRunUpdateAppsSuppressesUpToDateEntriesByDefault(t *testing.T) {
var stdout bytes.Buffer
var stderr bytes.Buffer

updated := runUpdateApps(cfg, c, updateOptions{}, updateDependencies{
updated := runUpgradeApps(cfg, c, upgradeOptions{}, upgradeDependencies{
runner: runner,
ghClient: ghClient,
installer: installer,
Expand All @@ -119,12 +119,12 @@ func TestRunUpdateAppsSuppressesUpToDateEntriesByDefault(t *testing.T) {
t.Fatalf("expected default output to suppress up-to-date entries, got %q", stdout.String())
}

progress := "Updating 'stale' from " + output.Green + "v1.0.0" + output.Reset + " to " + output.Cyan + "v1.1.0" + output.Reset
progress := "Upgrading 'stale' from " + output.Green + "v1.0.0" + output.Reset + " to " + output.Cyan + "v1.1.0" + output.Reset
if !strings.Contains(stdout.String(), progress) {
t.Fatalf("expected progress output %q, got %q", progress, stdout.String())
}

success := "Updated 'stale' to " + output.Green + "v1.1.0" + output.Reset
success := "Upgraded 'stale' to " + output.Green + "v1.1.0" + output.Reset
if !strings.Contains(stdout.String(), success) {
t.Fatalf("expected success output %q, got %q", success, stdout.String())
}
Expand All @@ -151,7 +151,7 @@ func TestRunUpdateAppsSuppressesUpToDateEntriesByDefault(t *testing.T) {
}
}

func TestRunUpdateAppsVerboseIncludesUpToDateEntries(t *testing.T) {
func TestRunUpgradeAppsVerboseIncludesUpToDateEntries(t *testing.T) {
cfg := &config.Config{
Apps: []config.App{
{Name: "current"},
Expand All @@ -175,7 +175,7 @@ func TestRunUpdateAppsVerboseIncludesUpToDateEntries(t *testing.T) {
var stdout bytes.Buffer
var stderr bytes.Buffer

updated := runUpdateApps(cfg, c, updateOptions{Verbose: true}, updateDependencies{
updated := runUpgradeApps(cfg, c, upgradeOptions{Verbose: true}, upgradeDependencies{
runner: runner,
ghClient: ghClient,
installer: installer,
Expand Down
Loading