Skip to content

Commit

Permalink
Rename vcs driver from "fake" to "local"
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia authored and salemhilal committed Jun 17, 2023
1 parent 41f8780 commit cb06690
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@
"base-url" : "{url}/{path}"
}
},
"FakeRepo": {
"url": "file:///absolute/path/to/directory",
"vcs": "fake",
"url-pattern" : {
"base-url" : "{url}/{path}"
},
"vcs-config": {
"detect-changes": false,
"ignored-files": []
}
},
"BitbucketServerUrl" : {
"url" : "git@bitbucket.internal.org:7999:organization/project.git",
"url-pattern" : {
Expand All @@ -101,6 +90,17 @@
"vcs-config" : {
"ref" : "main"
}
}
},
"LocalRepo": {
"url": "file:///absolute/path/to/directory",
"vcs": "local",
"url-pattern" : {
"base-url" : "{url}/{path}"
},
"vcs-config": {
"detect-changes": false,
"ignored-files": []
}
}
}
}
18 changes: 9 additions & 9 deletions vcs/fake.go → vcs/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import (
)

func init() {
Register(newFake, "fake")
Register(newLocal, "local")
}

type FakeDriver struct {
type LocalDriver struct {
DetectChanges bool `json:"detect-changes"`
IgnoredFiles []string `json:"ignored-files"`
}

func newFake(b []byte) (Driver, error) {
d := FakeDriver{}
func newLocal(b []byte) (Driver, error) {
d := LocalDriver{}

if b != nil {
if err := json.Unmarshal(b, &d); err != nil {
Expand Down Expand Up @@ -59,7 +59,7 @@ func myHash(files []string, open func(string) (io.ReadCloser, error)) (string, e
return hex.EncodeToString(h.Sum(nil)), nil
}

func (g *FakeDriver) HeadRev(dir string) (string, error) {
func (g *LocalDriver) HeadRev(dir string) (string, error) {
if !g.DetectChanges {
idx := strings.LastIndex(dir, "vcs-")
if idx == -1 {
Expand All @@ -81,11 +81,11 @@ func (g *FakeDriver) HeadRev(dir string) (string, error) {
return hash, err
}

func (g *FakeDriver) Pull(dir string) (string, error) {
func (g *LocalDriver) Pull(dir string) (string, error) {
return g.HeadRev(dir)
}

func (g *FakeDriver) Clone(dir, url string) (string, error) {
func (g *LocalDriver) Clone(dir, url string) (string, error) {
src := strings.TrimPrefix(url, "file://")
if !strings.HasPrefix(url, "file://") {
return "", fmt.Errorf("expected 'file://' prefix in url: %s", url)
Expand All @@ -96,10 +96,10 @@ func (g *FakeDriver) Clone(dir, url string) (string, error) {
return g.Pull(dir)
}

func (g *FakeDriver) SpecialFiles() []string {
func (g *LocalDriver) SpecialFiles() []string {
return g.IgnoredFiles
}

func (g *FakeDriver) AutoGeneratedFiles(dir string) []string {
func (g *LocalDriver) AutoGeneratedFiles(dir string) []string {
return []string{}
}

0 comments on commit cb06690

Please sign in to comment.