Skip to content

Commit

Permalink
Merge pull request #15 from awslabs/nofetch
Browse files Browse the repository at this point in the history
fix: remove remote operations
  • Loading branch information
lucix-aws committed Aug 15, 2023
2 parents b6ea859 + 5b0823d commit 380e484
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
11 changes: 4 additions & 7 deletions cmd/updaterequires/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"

repotools "github.com/awslabs/aws-go-multi-module-repository-tools"
"github.com/awslabs/aws-go-multi-module-repository-tools/git"
"github.com/awslabs/aws-go-multi-module-repository-tools/gomod"
"github.com/awslabs/aws-go-multi-module-repository-tools/release"
"io/ioutil"
"log"
)

var config = struct {
Expand Down Expand Up @@ -83,13 +84,9 @@ func getDependencies(path string) (map[string]string, error) {
}

func getRepoTags(path string) (git.ModuleTags, error) {
if err := git.Fetch(path); err != nil {
return nil, err
}

tags, err := git.Tags(path)
if err != nil {
return nil, err
return nil, fmt.Errorf("tags: %v", err)
}

return git.ParseModuleTags(tags), nil
Expand Down
26 changes: 11 additions & 15 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ func Tags(path string) ([]string, error) {
return splitOutput(string(output)), nil
}

// Fetch fetches all objects and refs for the Git repository located at path
func Fetch(path string) error {
_, err := Git(path, "fetch", "--all")
return err
}

// Git executes the git with the provided arguments. The command is executed in the provided
// directory path.
func Git(path string, arguments ...string) (output []byte, err error) {
Expand All @@ -56,18 +50,20 @@ func Git(path string, arguments ...string) (output []byte, err error) {
}
cmd.Dir = path
cmd.Env = append(os.Environ(), "PWD="+path)
cmd.Stderr = os.Stderr

return cmd.Output()
}

// ToModuleTag converts the relative module path and semver version string to a git tag
// that can be used to identify the module version.
// For example:
// Path: . Version: v1.2.3 => v1.2.3
// Path: service/s3 Version: v0.2.3 => service/s3/v0.2.3
// Path: service/s3 Version: v1.2.3 => service/s3/v1.2.3
// Path: service/s3/v2 Version: v2.2.3 => service/s3/v2.2.3
// Path: service/s3/v3 Version: v2.2.3 => error
//
// Path: . Version: v1.2.3 => v1.2.3
// Path: service/s3 Version: v0.2.3 => service/s3/v0.2.3
// Path: service/s3 Version: v1.2.3 => service/s3/v1.2.3
// Path: service/s3/v2 Version: v2.2.3 => service/s3/v2.2.3
// Path: service/s3/v3 Version: v2.2.3 => error
func ToModuleTag(modulePath string, version string) (string, error) {
major := semver.Major(version)
if len(major) == 0 {
Expand All @@ -94,11 +90,11 @@ func ToModuleTag(modulePath string, version string) (string, error) {
// following semantic versioning rules.
//
// Example:
// . => ["v1.2.3", "v1.0.0"]
// v2 => ["v2.0.0"]
// sub/module => ["v1.2.3"]
// sub/module/v2 => ["v2.2.3"]
//
// . => ["v1.2.3", "v1.0.0"]
// v2 => ["v2.0.0"]
// sub/module => ["v1.2.3"]
// sub/module/v2 => ["v2.2.3"]
type ModuleTags map[string][]string

// Latest returns the latest tag for the given relative module path. Returns false if
Expand Down

0 comments on commit 380e484

Please sign in to comment.