add submodules section of the .git/config
This commit is contained in:
parent
546ad6a842
commit
7d3e4ce84e
12
deps.go
12
deps.go
|
@ -13,7 +13,7 @@ func (rs *RepoStatus) GetGoDeps() GoConfig {
|
||||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
||||||
gosum, err := os.Open(tmp)
|
gosum, err := os.Open(tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log(WARN, "\tmissing go.sum", rs.realPath.String())
|
log.Log(REPO, "\tmissing go.sum", rs.realPath.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer gosum.Close()
|
defer gosum.Close()
|
||||||
|
@ -22,7 +22,7 @@ func (rs *RepoStatus) GetGoDeps() GoConfig {
|
||||||
deps = make(GoConfig)
|
deps = make(GoConfig)
|
||||||
|
|
||||||
scanner := bufio.NewScanner(gosum)
|
scanner := bufio.NewScanner(gosum)
|
||||||
log.Info("\tgosum:", tmp)
|
log.Log(REPO, "\tgosum:", tmp)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := strings.TrimSpace(scanner.Text())
|
line := strings.TrimSpace(scanner.Text())
|
||||||
|
|
||||||
|
@ -36,15 +36,15 @@ func (rs *RepoStatus) GetGoDeps() GoConfig {
|
||||||
currentversion, ok := deps[godep]
|
currentversion, ok := deps[godep]
|
||||||
if ok {
|
if ok {
|
||||||
if currentversion != version {
|
if currentversion != version {
|
||||||
log.Info("\tREPO:", rs.String(), rs.realPath.String())
|
log.Log(REPO, "\tREPO:", rs.String(), rs.realPath.String())
|
||||||
log.Info("\t version mismatch:", godep, version, currentversion)
|
log.Log(REPO, "\t version mismatch:", godep, version, currentversion)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deps[godep] = version
|
deps[godep] = version
|
||||||
log.Info("\t", godep, "=", version)
|
log.Log(REPO, "\t", godep, "=", version)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Info("\t INVALID:", parts)
|
log.Log(REPO, "\t INVALID:", parts)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
gitConfig.go
26
gitConfig.go
|
@ -2,7 +2,6 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -27,6 +26,7 @@ type GitConfig struct {
|
||||||
core map[string]string // map[origin] = "https:/git.wit.org/gui/gadgets"
|
core map[string]string // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||||
remotes map[string]*remote // map[origin] = "https:/git.wit.org/gui/gadgets"
|
remotes map[string]*remote // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||||
branches map[string]*branch // map[guimaster] = origin guimaster
|
branches map[string]*branch // map[guimaster] = origin guimaster
|
||||||
|
submodules map[string]string
|
||||||
hashes map[string]string
|
hashes map[string]string
|
||||||
versions map[string]string
|
versions map[string]string
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
||||||
file, err = os.Open(filename)
|
file, err = os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("couldn't open .git/config")
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
@ -97,6 +97,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
rs.gitConfig.core = make(map[string]string)
|
rs.gitConfig.core = make(map[string]string)
|
||||||
rs.gitConfig.remotes = make(map[string]*remote)
|
rs.gitConfig.remotes = make(map[string]*remote)
|
||||||
rs.gitConfig.branches = make(map[string]*branch)
|
rs.gitConfig.branches = make(map[string]*branch)
|
||||||
|
rs.gitConfig.submodules = make(map[string]string)
|
||||||
rs.gitConfig.versions = make(map[string]string)
|
rs.gitConfig.versions = make(map[string]string)
|
||||||
rs.gitConfig.hashes = make(map[string]string)
|
rs.gitConfig.hashes = make(map[string]string)
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
test.url = value
|
test.url = value
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Log(WARN, "error url mismatch", test.url, value)
|
log.Log(REPO, "error url mismatch", test.url, value)
|
||||||
case "fetch":
|
case "fetch":
|
||||||
if test.fetch == value {
|
if test.fetch == value {
|
||||||
continue
|
continue
|
||||||
|
@ -164,9 +165,9 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
test.fetch = value
|
test.fetch = value
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Log(WARN, "error fetch mismatch", test.fetch, value)
|
log.Log(REPO, "error fetch mismatch", test.fetch, value)
|
||||||
default:
|
default:
|
||||||
log.Log(WARN, "error unknown remote:", currentSection, currentName, "key", key, "value", value)
|
log.Log(REPO, "unknown remote:", rs.Path(), line)
|
||||||
}
|
}
|
||||||
case "branch":
|
case "branch":
|
||||||
test, ok := rs.gitConfig.branches[currentName]
|
test, ok := rs.gitConfig.branches[currentName]
|
||||||
|
@ -181,10 +182,21 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
case "merge":
|
case "merge":
|
||||||
rs.gitConfig.branches[currentName].merge = value
|
rs.gitConfig.branches[currentName].merge = value
|
||||||
default:
|
default:
|
||||||
log.Log(WARN, "error unknown remote:", currentSection, currentName, key, value)
|
log.Log(REPO, "error unknown remote:", currentSection, currentName, key, value)
|
||||||
|
log.Log(REPO, "unknown branch:", rs.Path(), line)
|
||||||
|
}
|
||||||
|
case "submodule":
|
||||||
|
// test, ok := rs.gitConfig.submodules[currentName]
|
||||||
|
switch key {
|
||||||
|
case "active":
|
||||||
|
// probably 'true' or 'false'
|
||||||
|
case "url":
|
||||||
|
rs.gitConfig.submodules[currentName] = value
|
||||||
|
default:
|
||||||
|
log.Log(REPOWARN, "unknown submodule line:", rs.Path(), line)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.Log(WARN, "error unknown currentSection", currentSection, "line:", line)
|
log.Log(REPOWARN, "unknown line:", rs.Path(), line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
new.go
21
new.go
|
@ -84,7 +84,11 @@ func guessPaths(path string) (string, string, string, bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("REPO_AUTO_CLONE") == "true" {
|
if os.Getenv("REPO_AUTO_CLONE") == "true" {
|
||||||
clone(goSrcDir, path)
|
err := Clone(goSrcDir, path)
|
||||||
|
if err != nil {
|
||||||
|
// directory doesn't exist. exit with nil and error nil
|
||||||
|
return path, realpath, goSrcDir, false, errors.New("git clone")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !IsDirectory(realpath) {
|
if !IsDirectory(realpath) {
|
||||||
|
@ -105,7 +109,7 @@ func guessPaths(path string) (string, string, string, bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to git clone if the go path doesn't exist
|
// attempt to git clone if the go path doesn't exist
|
||||||
func clone(wdir string, path string) error {
|
func Clone(wdir string, path string) error {
|
||||||
fullpath := filepath.Join(wdir, path)
|
fullpath := filepath.Join(wdir, path)
|
||||||
if IsDirectory(fullpath) {
|
if IsDirectory(fullpath) {
|
||||||
// directory already exists
|
// directory already exists
|
||||||
|
@ -116,13 +120,14 @@ func clone(wdir string, path string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
base := filepath.Join(wdir, filepath.Dir(path))
|
fulldir := filepath.Join(wdir, filepath.Dir(path))
|
||||||
os.MkdirAll(base, 0750)
|
base := filepath.Base(path)
|
||||||
err = os.Chdir(base)
|
os.MkdirAll(fulldir, 0750)
|
||||||
|
err = os.Chdir(fulldir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
shell.RunPath(base, []string{"git", "clone", "http://" + path})
|
shell.RunPath(fulldir, []string{"git", "clone", "http://" + path})
|
||||||
if IsDirectory(fullpath) {
|
if IsDirectory(fullpath) {
|
||||||
// clone worked
|
// clone worked
|
||||||
return nil
|
return nil
|
||||||
|
@ -132,7 +137,7 @@ func clone(wdir string, path string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info("URL:", url)
|
log.Info("URL:", url)
|
||||||
shell.RunPath(base, []string{"git", "clone", url})
|
shell.RunPath(fulldir, []string{"git", "clone", url, base})
|
||||||
if IsDirectory(fullpath) {
|
if IsDirectory(fullpath) {
|
||||||
// clone worked
|
// clone worked
|
||||||
return nil
|
return nil
|
||||||
|
@ -174,7 +179,7 @@ func findGoImport(url string) (string, error) {
|
||||||
}
|
}
|
||||||
tmp := strings.TrimSpace(parts[0])
|
tmp := strings.TrimSpace(parts[0])
|
||||||
fields := strings.Split(tmp, " ")
|
fields := strings.Split(tmp, " ")
|
||||||
log.Info("FIELDS:", fields)
|
// log.Info("FIELDS:", fields)
|
||||||
if len(fields) == 3 {
|
if len(fields) == 3 {
|
||||||
newurl = fields[2]
|
newurl = fields[2]
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue