Skip to content

Commit

Permalink
Fix: Bug that causes runtime error in "$ gup import"
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Mar 13, 2022
1 parent 812ab1e commit abd5306
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [0.7.4] - 2022-03-13
## Changed
- Fix: Bug that causes runtime error in "$ gup import"
This bug was caused by an insufficient setting of package version information.

# [0.7.2] - 2022-03-06
## Changed
- Fix: "commans" is a misspelling of "commands" (misspell) at cmd/update.go
Expand Down
2 changes: 1 addition & 1 deletion cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func validPkgInfo(pkgs []goutil.Package) []goutil.Package {
print.Warn("can't get '" + v.Name + "'package path information. old go version binary")
continue
}
result = append(result, goutil.Package{Name: v.Name, ImportPath: v.ImportPath})
result = append(result, goutil.Package{Name: v.Name, ImportPath: v.ImportPath, Version: v.Version})
}
return result
}
2 changes: 2 additions & 0 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ func runImport(cmd *cobra.Command, args []string) int {
if len(pkgs) == 0 {
print.Fatal("unable to update package: no package information")
}

print.Info("start update based on " + config.FilePath())
return update(pkgs, dryRun)
}
3 changes: 3 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func ReadConfFile() ([]goutil.Package, error) {
pkgs := []goutil.Package{}
for _, v := range contents {
pkg := goutil.Package{}
ver := goutil.Version{Current: "<from gup.conf>", Latest: ""}

v = deleteComment(v)
if isBlank(v) {
Expand All @@ -48,6 +49,7 @@ func ReadConfFile() ([]goutil.Package, error) {
equalIdx := strings.Index(v, "=")
pkg.Name = strings.TrimSpace(v[:equalIdx-1])
pkg.ImportPath = strings.TrimSpace(v[equalIdx+1:])
pkg.Version = &ver
pkgs = append(pkgs, pkg)
}

Expand All @@ -64,6 +66,7 @@ func WriteConfFile(pkgs []goutil.Package) error {

text := ""
for _, v := range pkgs {
// lost version information
text = text + fmt.Sprintf("%s = %s\n", v.Name, v.ImportPath)
}

Expand Down

0 comments on commit abd5306

Please sign in to comment.