Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
8e8d9e9a69 | |
|
b6a7af773d | |
|
bd05270a83 |
4
clone.go
4
clone.go
|
@ -173,6 +173,10 @@ func (f *Forge) urlClone(gopath, giturl string) (*gitpb.Repo, error) {
|
||||||
// for example:
|
// for example:
|
||||||
// This will check go.wit.com for "go.wit.com/apps/go-clone"
|
// This will check go.wit.com for "go.wit.com/apps/go-clone"
|
||||||
// and return where the URL to do git clone should be
|
// and return where the URL to do git clone should be
|
||||||
|
func FindGoImport(url string) (string, error) {
|
||||||
|
return findGoImport(url)
|
||||||
|
}
|
||||||
|
|
||||||
func findGoImport(url string) (string, error) {
|
func findGoImport(url string) (string, error) {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -84,6 +84,10 @@ type Origin struct {
|
||||||
|
|
||||||
// A Tags describes the available tags in a code repository.
|
// A Tags describes the available tags in a code repository.
|
||||||
|
|
||||||
|
func RunGoList(url string) (string, error) {
|
||||||
|
return runGoList(url)
|
||||||
|
}
|
||||||
|
|
||||||
func runGoList(url string) (string, error) {
|
func runGoList(url string) (string, error) {
|
||||||
ver, err := getLatestVersion(url)
|
ver, err := getLatestVersion(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
4
init.go
4
init.go
|
@ -145,6 +145,10 @@ func (f *Forge) InitPB() {
|
||||||
f.forgeURL = os.Getenv("FORGE_URL")
|
f.forgeURL = os.Getenv("FORGE_URL")
|
||||||
log.Info("got forge url", f.forgeURL)
|
log.Info("got forge url", f.forgeURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: play with these / determine good values based on user's machine
|
||||||
|
f.rillX = 10
|
||||||
|
f.rillY = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) InitMachine() {
|
func (f *Forge) InitMachine() {
|
||||||
|
|
40
repoNew.go
40
repoNew.go
|
@ -35,6 +35,25 @@ func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
|
||||||
return repo, nil
|
return repo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used by the forge daemon
|
||||||
|
func (f *Forge) AddNamespaceDir(ns string, fullpath string) (*gitpb.Repo, error) {
|
||||||
|
test := f.Repos.FindByNamespace(ns)
|
||||||
|
if test != nil {
|
||||||
|
return test, fmt.Errorf("already have namespace")
|
||||||
|
}
|
||||||
|
repo, err := f.Repos.NewGoRepo(fullpath, ns)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("WARNING. NEW FAILED", fullpath)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// slices.Reverse(f.Repos.Repos)
|
||||||
|
|
||||||
|
// repo.URL = url
|
||||||
|
f.VerifyBranchNames(repo)
|
||||||
|
repo.Reload()
|
||||||
|
return repo, nil
|
||||||
|
}
|
||||||
|
|
||||||
func isValidSemVer(version string) bool {
|
func isValidSemVer(version string) bool {
|
||||||
// Regular expression for semantic versioning
|
// Regular expression for semantic versioning
|
||||||
regex := `^v(\d+)\.(\d+)\.(\d+)$`
|
regex := `^v(\d+)\.(\d+)\.(\d+)$`
|
||||||
|
@ -103,13 +122,6 @@ func (f *Forge) findMasterBranch(repo *gitpb.Repo) {
|
||||||
|
|
||||||
// TODO: figure out the name from git
|
// TODO: figure out the name from git
|
||||||
repo.SetMasterBranchName("master")
|
repo.SetMasterBranchName("master")
|
||||||
/* no longer checkout on Init()
|
|
||||||
if repo.CheckoutMaster() {
|
|
||||||
} else {
|
|
||||||
cmd := []string{"git", "branch", "master"}
|
|
||||||
repo.Run(cmd)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out what the name of the git devel branch is
|
// figure out what the name of the git devel branch is
|
||||||
|
@ -118,13 +130,6 @@ func (f *Forge) findDevelBranch(repo *gitpb.Repo) {
|
||||||
// check the forge config first
|
// check the forge config first
|
||||||
if bname := f.Config.FindDevelBranch(repo.GetGoPath()); bname != "" {
|
if bname := f.Config.FindDevelBranch(repo.GetGoPath()); bname != "" {
|
||||||
repo.SetDevelBranchName(bname)
|
repo.SetDevelBranchName(bname)
|
||||||
/* no longer checkout on Init()
|
|
||||||
if repo.CheckoutDevel() {
|
|
||||||
} else {
|
|
||||||
cmd := []string{"git", "branch", bname}
|
|
||||||
repo.Run(cmd)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,13 +139,6 @@ func (f *Forge) findDevelBranch(repo *gitpb.Repo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.SetDevelBranchName("devel")
|
repo.SetDevelBranchName("devel")
|
||||||
/* no longer checkout on Init()
|
|
||||||
if repo.CheckoutDevel() {
|
|
||||||
} else {
|
|
||||||
cmd := []string{"git", "branch", "devel"}
|
|
||||||
repo.Run(cmd)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is still in flux
|
// this is still in flux
|
||||||
|
|
20
rill.go
20
rill.go
|
@ -150,13 +150,19 @@ func (f *Forge) RillFuncError(rillf func(*gitpb.Repo) error) int {
|
||||||
return counter
|
return counter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Forge) ConfigRill(rillX int, rillY int) {
|
||||||
|
}
|
||||||
|
|
||||||
// x is the size of the queued up pool (shouldn't matter here for this I think)
|
// x is the size of the queued up pool (shouldn't matter here for this I think)
|
||||||
// y is how many simultanous functions will run
|
// y is how many simultanous functions will run
|
||||||
// todo: tune and compute x,y by # of CPUs and disk io
|
// todo: tune and compute x,y by # of CPUs and disk io
|
||||||
// todo: store x,y in forge config ? (or compute them. notsure)
|
// todo: store x,y in forge config ? (or compute them. notsure)
|
||||||
func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (int, error) {
|
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
||||||
var anyerr error
|
|
||||||
var all []*gitpb.Repo
|
var all []*gitpb.Repo
|
||||||
|
|
||||||
|
var allerr map[*gitpb.Repo]error
|
||||||
|
allerr = make(map[*gitpb.Repo]error)
|
||||||
|
|
||||||
for repo := range f.Repos.IterAll() {
|
for repo := range f.Repos.IterAll() {
|
||||||
if !repo.IsValidDir() {
|
if !repo.IsValidDir() {
|
||||||
log.Printf("%s %-50s", "got an invalid repo in forgepb.RillFuncError()", repo.GetGoPath())
|
log.Printf("%s %-50s", "got an invalid repo in forgepb.RillFuncError()", repo.GetGoPath())
|
||||||
|
@ -173,11 +179,11 @@ func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (i
|
||||||
|
|
||||||
// Read users from the API.
|
// Read users from the API.
|
||||||
// Concurrency = 20
|
// Concurrency = 20
|
||||||
dirs := rill.Map(ids, rillX, func(id *gitpb.Repo) (*gitpb.Repo, error) {
|
dirs := rill.Map(ids, f.rillX, func(id *gitpb.Repo) (*gitpb.Repo, error) {
|
||||||
return id, nil
|
return id, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
rill.ForEach(dirs, rillY, func(repo *gitpb.Repo) error {
|
rill.ForEach(dirs, f.rillY, func(repo *gitpb.Repo) error {
|
||||||
meMu.Lock()
|
meMu.Lock()
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter > watch {
|
if counter > watch {
|
||||||
|
@ -186,10 +192,12 @@ func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (i
|
||||||
}
|
}
|
||||||
meMu.Unlock()
|
meMu.Unlock()
|
||||||
if err := rillf(repo); err != nil {
|
if err := rillf(repo); err != nil {
|
||||||
anyerr = err
|
meMu.Lock()
|
||||||
|
allerr[repo] = err
|
||||||
|
meMu.Unlock()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return counter, anyerr
|
return allerr
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@ type Forge struct {
|
||||||
fullscan time.Time // time of the last scan so it can be throttled
|
fullscan time.Time // time of the last scan so it can be throttled
|
||||||
hostname string // your hostname
|
hostname string // your hostname
|
||||||
forgeURL string // URL to use to forge.wit.com
|
forgeURL string // URL to use to forge.wit.com
|
||||||
// Machine *zoopb.Machine // things for virtigo to track vm's
|
rillX int // used for Rill()
|
||||||
|
rillY int // used for Rill()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) GetGoSrc() string {
|
func (f *Forge) GetGoSrc() string {
|
||||||
|
|
Loading…
Reference in New Issue