Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added flag cachePath #59

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Available options:

* `--path` is the path of the repository to split (current directory by default);

* `--cachePath` cache path (optional, inherits --path value by default);

* `--origin` is the Git reference for the origin (can be any Git reference
like `HEAD`, `heads/xxx`, `tags/xxx`, `origin/xxx`, or any `refs/xxx`);

Expand Down
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/splitsh/lite/splitter"
"./splitter"
)

var (
Expand Down Expand Up @@ -41,7 +41,7 @@ func (p *prefixesFlag) Set(value string) error {
}

var prefixes prefixesFlag
var origin, target, commit, path, gitVersion string
var origin, target, commit, path, cachePath, gitVersion string
var scratch, debug, quiet, legacy, progress, v bool

func init() {
Expand All @@ -50,6 +50,7 @@ func init() {
flag.StringVar(&target, "target", "", "The branch to create when split is finished (optional)")
flag.StringVar(&commit, "commit", "", "The commit at which to start the split (optional)")
flag.StringVar(&path, "path", ".", "The repository path (optional, current directory by default)")
flag.StringVar(&cachePath, "cachePath", "", "The cache path (optional, inherits --path value by default)")
flag.BoolVar(&scratch, "scratch", false, "Flush the cache (optional)")
flag.BoolVar(&debug, "debug", false, "Enable the debug mode (optional)")
flag.BoolVar(&quiet, "quiet", false, "[DEPRECATED] Suppress the output (optional)")
Expand Down Expand Up @@ -81,8 +82,13 @@ func main() {
fmt.Fprintln(os.Stderr, `The --quiet option is deprecated (append 2>/dev/null to the command instead)`)
}

if cachePath == "" {
cachePath = path
}

config := &splitter.Config{
Path: path,
CachePath: cachePath,
Origin: origin,
Prefixes: []*splitter.Prefix(prefixes),
Target: target,
Expand Down
2 changes: 1 addition & 1 deletion splitter/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func newCache(branch string, config *Config) (*cache, error) {
var err error
db := config.DB
if db == nil {
db, err = bolt.Open(filepath.Join(GitDirectory(config.Path), "splitsh.db"), 0644, &bolt.Options{Timeout: 5 * time.Second})
db, err = bolt.Open(filepath.Join(GitDirectory(config.CachePath), "splitsh.db"), 0644, &bolt.Options{Timeout: 5 * time.Second})
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions splitter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Prefix struct {
type Config struct {
Prefixes []*Prefix
Path string
CachePath string
Origin string
Commit string
Target string
Expand Down