summaryrefslogtreecommitdiff
path: root/repo.new.go
blob: c7f000f5f632ca8565e1ba3f24d834506ec4549c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package gitpb

import (
	"path/filepath"
)

// scans in a new git repo. If it detects the repo is a golang project,
// then it parses the go.mod/go.sum files
// TODO: try adding python, rails, perl, rust, other language things?
// I probably will never have time to try that, but I'd take patches for anyone
// that might see this note and feel so inclined.
func (all *Repos) NewGoPath(basepath string, gopath string) *Repo {
	if r := all.FindByGoPath(gopath); r != nil {
		// already had this gopath
		return r
	}
	// add a new one here
	newr := Repo{
		FullPath: filepath.Join(basepath, gopath),
		GoPath:   gopath,
	}
	newr.UpdateGit()

	all.add(&newr)
	return &newr
}