Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove remote operations #15

Merged
merged 1 commit into from
Aug 15, 2023
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
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
Loading