Skip to content

Commit

Permalink
update project namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed May 14, 2024
1 parent c2d211f commit 86e68ec
Show file tree
Hide file tree
Showing 88 changed files with 193 additions and 159 deletions.
5 changes: 4 additions & 1 deletion app/app_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/permafrost-dev/eget/lib/home"
"github.com/permafrost-dev/zeget/lib/home"
pb "github.com/schollz/progressbar/v3"
)

Expand All @@ -29,6 +29,9 @@ func tokenFrom(s string) (string, error) {
var ErrNoToken = errors.New("no github token")

func getGithubToken() (string, error) {
if os.Getenv("ZEGET_GITHUB_TOKEN") != "" {
return tokenFrom(os.Getenv("ZEGET_GITHUB_TOKEN"))
}
if os.Getenv("EGET_GITHUB_TOKEN") != "" {
return tokenFrom(os.Getenv("EGET_GITHUB_TOKEN"))
}
Expand Down
19 changes: 12 additions & 7 deletions app/app_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package app

import (
"fmt"

"github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/eget/lib/assets"
"github.com/permafrost-dev/eget/lib/detectors"
"github.com/permafrost-dev/eget/lib/reporters"
"github.com/permafrost-dev/eget/lib/utilities"
. "github.com/permafrost-dev/eget/lib/utilities"
"time"

"github.com/permafrost-dev/zeget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
"github.com/permafrost-dev/zeget/lib/detectors"
"github.com/permafrost-dev/zeget/lib/reporters"
"github.com/permafrost-dev/zeget/lib/utilities"
. "github.com/permafrost-dev/zeget/lib/utilities"
)

func (app *Application) Run() *ReturnStatus {
Expand All @@ -29,6 +30,10 @@ func (app *Application) Run() *ReturnStatus {
}

app.RefreshRateLimit()
if err := app.RateLimitExceeded(); err != nil {
app.WriteErrorLine("GitHub rate limit exceeded. It resets at %s.", app.Cache.Data.RateLimit.Reset.Format(time.RFC1123))
return NewReturnStatus(FatalError, nil, fmt.Sprintf("error: %v", err))
}

finder := app.getFinder()
findResult := app.getFindResult(finder)
Expand Down
54 changes: 40 additions & 14 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ import (
"time"

"github.com/jessevdk/go-flags"
. "github.com/permafrost-dev/eget/lib/appflags"
. "github.com/permafrost-dev/eget/lib/assets"
"github.com/permafrost-dev/eget/lib/data"
"github.com/permafrost-dev/eget/lib/download"
. "github.com/permafrost-dev/eget/lib/extraction"
"github.com/permafrost-dev/eget/lib/filters"
"github.com/permafrost-dev/eget/lib/finders"
"github.com/permafrost-dev/eget/lib/github"
. "github.com/permafrost-dev/eget/lib/globals"
"github.com/permafrost-dev/eget/lib/home"
"github.com/permafrost-dev/eget/lib/utilities"
. "github.com/permafrost-dev/eget/lib/utilities"
"github.com/permafrost-dev/eget/lib/verifiers"
. "github.com/permafrost-dev/zeget/lib/appflags"
. "github.com/permafrost-dev/zeget/lib/assets"
"github.com/permafrost-dev/zeget/lib/data"
"github.com/permafrost-dev/zeget/lib/download"
. "github.com/permafrost-dev/zeget/lib/extraction"
"github.com/permafrost-dev/zeget/lib/filters"
"github.com/permafrost-dev/zeget/lib/finders"
"github.com/permafrost-dev/zeget/lib/github"
. "github.com/permafrost-dev/zeget/lib/globals"
"github.com/permafrost-dev/zeget/lib/home"
"github.com/permafrost-dev/zeget/lib/utilities"
. "github.com/permafrost-dev/zeget/lib/utilities"
"github.com/permafrost-dev/zeget/lib/verifiers"
"github.com/twpayne/go-vfs/v5"
)

Expand Down Expand Up @@ -150,7 +150,7 @@ func (app *Application) cacheTarget(finding *finders.ValidFinder, findResult *fi
finding.Tool,
app.Opts.Asset,
findResult,
time.Now().Add(time.Hour*48),
time.Now().Add(time.Hour*24*7),
)
}

Expand Down Expand Up @@ -223,7 +223,33 @@ func (app *Application) selectFromMultipleCandidates(bin ExtractedFile, bins []E
return bin, nil
}

func (app *Application) RateLimitExceeded() error {
if app.Cache.Data.RateLimit.Remaining < 10 {
return errors.New("GitHub rate limit exceeded")
}

return nil
}

func (app *Application) RefreshRateLimit() error {
//diff in minutes between the current time and the rate limit reset time:
diff := app.Cache.Data.RateLimit.Reset.Sub(time.Now().Local()).Round(time.Second).Seconds() / 60

// not a percentage per se, but the rate limit remaining divided by the number of minutes until the rate limit resets
// provides a rough estimate of the rate of requests that can be made per minute until the rate limit resets.
rate := int64(app.Cache.Data.RateLimit.Remaining) / int64(diff)

// fmt.Printf("Rate limit reset in %v ,minutes\n", diff)
// fmt.Printf("Remaining rate limit: %d\n", app.Cache.Data.RateLimit.Remaining)
// fmt.Printf("Total rate limit: %d\n", rate)

// if rate is <50, always refresh the rate limit
if app.Cache.Data.RateLimit.Reset != nil && rate > 50 {
if app.Cache.Data.RateLimit.Reset.After(time.Now().Local()) {
return errors.New("rate limit has not reset")
}
}

rateLimitDate, err := github.FetchRateLimit(app.DownloadClient())

if err == nil {
Expand Down
6 changes: 3 additions & 3 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"runtime"

"github.com/BurntSushi/toml"
"github.com/permafrost-dev/eget/lib/globals"
"github.com/permafrost-dev/eget/lib/home"
"github.com/permafrost-dev/eget/lib/utilities"
"github.com/permafrost-dev/zeget/lib/globals"
"github.com/permafrost-dev/zeget/lib/home"
"github.com/permafrost-dev/zeget/lib/utilities"
"github.com/twpayne/go-vfs/v5"
)

Expand Down
4 changes: 2 additions & 2 deletions app/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/app"
. "github.com/permafrost-dev/eget/lib/globals"
. "github.com/permafrost-dev/zeget/app"
. "github.com/permafrost-dev/zeget/lib/globals"
)

var _ = Describe("Config", func() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/permafrost-dev/eget
module github.com/permafrost-dev/zeget

go 1.21

Expand Down
2 changes: 1 addition & 1 deletion lib/appflags/flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package appflags

import "github.com/permafrost-dev/eget/lib/filters"
import "github.com/permafrost-dev/zeget/lib/filters"

type Flags struct {
Tag string
Expand Down
2 changes: 1 addition & 1 deletion lib/archives/TarArchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"io/fs"

"github.com/permafrost-dev/eget/lib/files"
"github.com/permafrost-dev/zeget/lib/files"
)

type TarArchive struct {
Expand Down
4 changes: 2 additions & 2 deletions lib/archives/TarArchive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/archives" // Replace with the actual import path of your package
"github.com/permafrost-dev/eget/lib/files"
. "github.com/permafrost-dev/zeget/lib/archives" // Replace with the actual import path of your package
"github.com/permafrost-dev/zeget/lib/files"
)

var _ = Describe("TarArchive", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/archives/ZipArchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"strings"

"github.com/permafrost-dev/eget/lib/files"
"github.com/permafrost-dev/zeget/lib/files"
)

type ZipArchive struct {
Expand Down
4 changes: 2 additions & 2 deletions lib/archives/ZipArchive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/archives"
"github.com/permafrost-dev/eget/lib/files"
. "github.com/permafrost-dev/zeget/lib/archives"
"github.com/permafrost-dev/zeget/lib/files"
)

var _ = Describe("ZipArchive", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package archives
import (
"io"

"github.com/permafrost-dev/eget/lib/files"
"github.com/permafrost-dev/zeget/lib/files"
)

type ArchiveFunc func(data []byte, decomp DecompressFunc) (Archive, error)
Expand Down
2 changes: 1 addition & 1 deletion lib/archives/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package archives
import (
"archive/tar"

"github.com/permafrost-dev/eget/lib/files"
"github.com/permafrost-dev/zeget/lib/files"
)

func TarFileType(typ byte) files.FileType {
Expand Down
4 changes: 2 additions & 2 deletions lib/archives/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/permafrost-dev/eget/lib/archives"
"github.com/permafrost-dev/eget/lib/files"
"github.com/permafrost-dev/zeget/lib/archives"
"github.com/permafrost-dev/zeget/lib/files"
)

var _ = Describe("Helpers", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/assets/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package assets_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
)

var _ = Describe("lib/assets > Asset", func() {
Expand Down
4 changes: 2 additions & 2 deletions lib/data/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

ulid "github.com/oklog/ulid/v2"
"github.com/permafrost-dev/eget/lib/finders"
"github.com/permafrost-dev/eget/lib/utilities"
"github.com/permafrost-dev/zeget/lib/finders"
"github.com/permafrost-dev/zeget/lib/utilities"
)

type Cache struct {
Expand Down
6 changes: 3 additions & 3 deletions lib/data/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/eget/lib/data"
"github.com/permafrost-dev/eget/lib/finders"
"github.com/permafrost-dev/zeget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/data"
"github.com/permafrost-dev/zeget/lib/finders"
)

var _ = Describe("Cache", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/data/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package data
import (
"time"

"github.com/permafrost-dev/eget/lib/assets"
"github.com/permafrost-dev/zeget/lib/assets"
)

type RateLimit struct {
Expand Down
2 changes: 1 addition & 1 deletion lib/data/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/permafrost-dev/eget/lib/data"
"github.com/permafrost-dev/zeget/lib/data"
)

var _ = Describe("ApplicationData", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/all_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package detectors
import (
"fmt"

. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
)

// AllDetector matches every asset. If there is only one asset, it is returned
Expand Down
4 changes: 2 additions & 2 deletions lib/detectors/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"runtime"
"strings"

"github.com/permafrost-dev/eget/lib/appflags"
. "github.com/permafrost-dev/eget/lib/assets"
"github.com/permafrost-dev/zeget/lib/appflags"
. "github.com/permafrost-dev/zeget/lib/assets"
)

// A Detector selects an asset from a list of possibilities.
Expand Down
6 changes: 3 additions & 3 deletions lib/detectors/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"runtime"
"testing"

"github.com/permafrost-dev/eget/lib/appflags"
. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/eget/lib/detectors"
"github.com/permafrost-dev/zeget/lib/appflags"
. "github.com/permafrost-dev/zeget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/detectors"
)

func TestAllDetector_Detect(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/detection_result.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package detectors

import "github.com/permafrost-dev/eget/lib/assets"
import "github.com/permafrost-dev/zeget/lib/assets"

type DetectionResult struct {
Asset assets.Asset
Expand Down
4 changes: 2 additions & 2 deletions lib/detectors/detection_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package detectors_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/detectors"
. "github.com/permafrost-dev/zeget/lib/detectors"

"github.com/permafrost-dev/eget/lib/assets"
"github.com/permafrost-dev/zeget/lib/assets"
)

var _ = Describe("lib/detectors > DetectionResult", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/detector_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package detectors
import (
"fmt"

. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
)

type DetectorChain struct {
Expand Down
4 changes: 2 additions & 2 deletions lib/detectors/detector_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/eget/lib/detectors"
. "github.com/permafrost-dev/zeget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/detectors"
)

type MockDetector struct {
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/detectors"
. "github.com/permafrost-dev/zeget/lib/detectors"
)

var _ = Describe("OS", func() {
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/single_asset_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path"
"strings"

. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
)

// SingleAssetDetector finds a single named asset. If Anti is true it finds all
Expand Down
2 changes: 1 addition & 1 deletion lib/detectors/system_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/assets"
)

// A SystemDetector matches a particular OS/Arch system pair.
Expand Down
4 changes: 2 additions & 2 deletions lib/detectors/system_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package detectors_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/permafrost-dev/eget/lib/assets"
. "github.com/permafrost-dev/eget/lib/detectors"
. "github.com/permafrost-dev/zeget/lib/assets"
. "github.com/permafrost-dev/zeget/lib/detectors"
)

var _ = Describe("SystemDetector", func() {
Expand Down
Loading

0 comments on commit 86e68ec

Please sign in to comment.