aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-11-02 15:01:08 +0700
committerShulhan <ms@kilabit.info>2018-11-02 15:01:08 +0700
commit3faf2e85befd710a26379cd1a04b9e243cefb04d (patch)
tree797ec7de212069d7438bf361fda529b50c7013f0
parentcb6e819afd85ca2d561c221848904a783a6595f5 (diff)
downloadbeku-3faf2e85befd710a26379cd1a04b9e243cefb04d.tar.xz
Fix sync all that cause version set to truev0.5.1
While at it, reupdate the comments section on some methods.
-rw-r--r--cmd/beku/command.go18
-rw-r--r--cmd/beku/main.go7
-rw-r--r--env.go38
-rw-r--r--package.go2
4 files changed, 20 insertions, 45 deletions
diff --git a/cmd/beku/command.go b/cmd/beku/command.go
index 208075f..100f8a1 100644
--- a/cmd/beku/command.go
+++ b/cmd/beku/command.go
@@ -13,13 +13,6 @@ import (
"github.com/shuLhan/share/lib/debug"
)
-const (
- verMajor = 0
- verMinor = 5
- verPatch = 0
- verMetadata = ""
-)
-
var (
errInvalidOptions = errors.New("error: invalid options")
errMultiOperations = errors.New("error: only at operation may be used at a time")
@@ -289,10 +282,6 @@ func (cmd *command) parseLongFlags(arg string) (op operation, err error) {
//
// parseFlags for multiple operations, invalid options, or empty targets.
//
-// (0) "-h", "--help", "--version" flag is a stopper.
-// (1) Only one operation is allowed.
-// (2) "-R" or "-S" must have target
-//
func (cmd *command) parseFlags(args []string) (err error) {
if len(args) == 0 {
return errNoOperation
@@ -335,7 +324,8 @@ func (cmd *command) parseFlags(args []string) (err error) {
}
break
}
- // (0)
+
+ // "-h", "--help", "--version" flag is a stopper.
if op == opHelp || op == opVersion {
cmd.op = op
return
@@ -353,14 +343,14 @@ func (cmd *command) parseFlags(args []string) (err error) {
}
}
- // (1)
+ // Only one operation is allowed.
op = cmd.op & (opDatabase | opFreeze | opQuery | opRemove | opSync)
if op != opDatabase && op != opFreeze && op != opQuery &&
op != opRemove && op != opSync {
return errMultiOperations
}
- // (2)
+ // "-R" or "-S" must have target
if op == opRemove {
if len(cmd.pkgs) == 0 {
return errNoTarget
diff --git a/cmd/beku/main.go b/cmd/beku/main.go
index c414dd3..5395ee6 100644
--- a/cmd/beku/main.go
+++ b/cmd/beku/main.go
@@ -17,6 +17,13 @@ import (
"os"
)
+const (
+ verMajor = 0
+ verMinor = 5
+ verPatch = 1
+ verMetadata = ""
+)
+
func main() {
cmd, err := newCommand()
if err != nil {
diff --git a/env.go b/env.go
index 81c13e5..daf81b6 100644
--- a/env.go
+++ b/env.go
@@ -315,12 +315,10 @@ func (env *Env) GetUnused(srcPath string) (err error) {
fullPath := filepath.Join(srcPath, dirName)
dirGit := filepath.Join(fullPath, gitDir)
- // (1)
if IsIgnoredDir(dirName) {
continue
}
- // (2)
_, err = os.Stat(dirGit)
if err != nil {
nextScan = append(nextScan, fullPath)
@@ -397,9 +395,6 @@ func (env *Env) Scan() (err error) {
// until no subdirectory found. All path to subdirectories will be saved on
// Environment `pkgsStd`.
//
-// (0) skip file
-// (1) skip ignored directory
-//
func (env *Env) scanStdPackages(srcPath string) error {
fis, err := ioutil.ReadDir(srcPath)
if err != nil {
@@ -408,7 +403,7 @@ func (env *Env) scanStdPackages(srcPath string) error {
}
for _, fi := range fis {
- // (0)
+ // Skip non directory.
if !fi.IsDir() {
continue
}
@@ -416,7 +411,6 @@ func (env *Env) scanStdPackages(srcPath string) error {
dirName := fi.Name()
fullPath := filepath.Join(srcPath, dirName)
- // (1)
if IsIgnoredDir(dirName) {
continue
}
@@ -432,10 +426,6 @@ func (env *Env) scanStdPackages(srcPath string) error {
// scanPackages will traverse each directory in `src` recursively until
// it's found VCS metadata, e.g. `.git` directory.
//
-// (0) skip file
-// (1) skip ignored directory
-// (2) skip directory without `.git`
-//
func (env *Env) scanPackages(srcPath string) (err error) {
if debug.Value >= 1 {
fmt.Println("[ENV] scanPackages >>>", srcPath)
@@ -463,12 +453,11 @@ func (env *Env) scanPackages(srcPath string) (err error) {
fullPath := filepath.Join(srcPath, dirName)
dirGit := filepath.Join(fullPath, gitDir)
- // (1)
if IsIgnoredDir(dirName) {
continue
}
- // (2)
+ // Skip directory that contains ".git".
_, err = os.Stat(dirGit)
if err != nil {
nextRoot = append(nextRoot, fullPath)
@@ -1278,7 +1267,7 @@ func (env *Env) SyncAll() (err error) {
if pkg.Version >= pkg.VersionNext {
fmt.Printf("[ENV] SyncAll %s >>> No update.\n\n",
pkg.ImportPath)
- pkg.VersionNext = ""
+ pkg.VersionNext = pkg.Version
continue
}
@@ -1334,14 +1323,9 @@ func (env *Env) SyncAll() (err error) {
return
}
-//
-// (1) Update missing packages.
-// (2) Run build command if its applicable
-// (3) Run `go install` only if no missing package.
-//
func (env *Env) postSync(pkg *Package) (err error) {
fmt.Printf("\n[ENV] postSync %s\n", pkg.ImportPath)
- // (1)
+ // Update missing packages.
env.updateMissing(pkg, true)
err = env.build(pkg)
@@ -1349,7 +1333,7 @@ func (env *Env) postSync(pkg *Package) (err error) {
return
}
- // (3)
+ // Run `go install` only if no missing package.
if len(pkg.DepsMissing) == 0 {
_ = pkg.GoInstall(env.path)
}
@@ -1359,21 +1343,15 @@ func (env *Env) postSync(pkg *Package) (err error) {
return
}
-//
-// (1) Re-scan package dependencies.
-// (2) Install missing dependencies.
-//
func (env *Env) build(pkg *Package) (err error) {
- // (1)
+ // Re-scan package dependencies.
err = pkg.ScanDeps(env)
if err != nil {
return
}
- // (2)
- err = env.installMissing(pkg)
-
- return
+ // Install missing dependencies.
+ return env.installMissing(pkg)
}
func (env *Env) reinstallAll() (err error) {
diff --git a/package.go b/package.go
index 8b27e54..e073937 100644
--- a/package.go
+++ b/package.go
@@ -471,7 +471,7 @@ func (pkg *Package) load(sec *ini.Section) {
//
// GoInstall a package recursively ("./...").
//
-// (1) Set PATH to let go install that require gcc work when invoked from
+// Set PATH to let go install that require gcc work when invoked from
// non-interactive shell (e.g. buildbot).
//
func (pkg *Package) GoInstall(envPath string) (err error) {