mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
Support pijul
This commit is contained in:
parent
7163e61e23
commit
dafa59dfa6
|
|
@ -72,6 +72,11 @@ func TestDoCreate(t *testing.T) {
|
|||
input: []string{"create", "--vcs=darcs", "motemen/ghq-darcs"},
|
||||
want: []string{"darcs", "init"},
|
||||
wantDir: filepath.Join(tmpd, "github.com/motemen/ghq-darcs"),
|
||||
}, {
|
||||
name: "Pijul",
|
||||
input: []string{"create", "--vcs=pijul", "motemen/ghq-pijul"},
|
||||
want: []string{"pijul", "init"},
|
||||
wantDir: filepath.Join(tmpd, "github.com/motemen/ghq-pijul"),
|
||||
}, {
|
||||
name: "Bazzar",
|
||||
input: []string{"create", "--vcs=bzr", "motemen/ghq-bzr"},
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ var vcsContentsMap = map[string]*VCSBackend{
|
|||
".hg": MercurialBackend,
|
||||
".svn": SubversionBackend,
|
||||
"_darcs": DarcsBackend,
|
||||
".pijul": PijulBackend,
|
||||
".bzr": BazaarBackend,
|
||||
".fslckout": FossilBackend, // file
|
||||
"_FOSSIL_": FossilBackend, // file
|
||||
|
|
@ -219,6 +220,7 @@ var vcsContents = [...]string{
|
|||
".hg",
|
||||
".svn",
|
||||
"_darcs",
|
||||
".pijul",
|
||||
".bzr",
|
||||
".fslckout",
|
||||
"._FOSSIL_",
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ var logger = colorine.NewLogger(
|
|||
"hg": colorine.Verbose,
|
||||
"svn": colorine.Verbose,
|
||||
"darcs": colorine.Verbose,
|
||||
"pijul": colorine.Verbose,
|
||||
"bzr": colorine.Verbose,
|
||||
"fossil": colorine.Verbose,
|
||||
"skip": colorine.Verbose,
|
||||
|
|
|
|||
|
|
@ -93,6 +93,26 @@ func (repo *DarksHubRepository) VCS() (*VCSBackend, *url.URL, error) {
|
|||
return DarcsBackend, repo.URL(), nil
|
||||
}
|
||||
|
||||
// NestPijulRepository represents the Nest repository
|
||||
type NestPijulRepository struct {
|
||||
url *url.URL
|
||||
}
|
||||
|
||||
// URL returns URL of the Nest repository
|
||||
func (repo *NestPijulRepository) URL() *url.URL {
|
||||
return repo.url
|
||||
}
|
||||
|
||||
// IsValid determine if the Nest repository is valid or not
|
||||
func (repo *NestPijulRepository) IsValid() bool {
|
||||
return strings.Count(repo.url.Path, "/") == 2
|
||||
}
|
||||
|
||||
// VCS returns VCSBackend of the Nest repository
|
||||
func (repo *NestPijulRepository) VCS() (*VCSBackend, *url.URL, error) {
|
||||
return PijulBackend, repo.URL(), nil
|
||||
}
|
||||
|
||||
// A CodeCommitRepository represents a CodeCommit repository. Implements RemoteRepository.
|
||||
type CodeCommitRepository struct {
|
||||
url *url.URL
|
||||
|
|
@ -197,6 +217,8 @@ func NewRemoteRepository(u *url.URL) (RemoteRepository, error) {
|
|||
return &GitHubGistRepository{u}
|
||||
case "hub.darcs.net":
|
||||
return &DarksHubRepository{u}
|
||||
case "nest.pijul.com":
|
||||
return &NestPijulRepository{u}
|
||||
default:
|
||||
return &OtherRepository{u}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ func TestNewRemoteRepository(t *testing.T) {
|
|||
url: "http://hub.darcs.net/foo/bar",
|
||||
valid: true,
|
||||
vcsBackend: DarcsBackend,
|
||||
}, {
|
||||
url: "http://nest.pijul.com/foo/bar",
|
||||
valid: true,
|
||||
vcsBackend: PijulBackend,
|
||||
}, {
|
||||
url: "svn+ssh://example.com/proj/repo",
|
||||
valid: true,
|
||||
|
|
|
|||
28
vcs.go
28
vcs.go
|
|
@ -297,6 +297,33 @@ var DarcsBackend = &VCSBackend{
|
|||
Contents: []string{"_darcs"},
|
||||
}
|
||||
|
||||
// PijulBackend is the VCSBackend for pijul
|
||||
var PijulBackend = &VCSBackend{
|
||||
Clone: func(vg *vcsGetOption) error {
|
||||
if vg.branch != "" {
|
||||
return errors.New("pijul does not support branch")
|
||||
}
|
||||
|
||||
dir, _ := filepath.Split(vg.dir)
|
||||
err := os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
args := []string{"clone"}
|
||||
args = append(args, vg.url.String(), vg.dir)
|
||||
|
||||
return run(vg.silent)("pijul", args...)
|
||||
},
|
||||
Update: func(vg *vcsGetOption) error {
|
||||
return runInDir(vg.silent)(vg.dir, "pijul", "pull")
|
||||
},
|
||||
Init: func(dir string) error {
|
||||
return cmdutil.RunInDir(dir, "pijul", "init")
|
||||
},
|
||||
Contents: []string{".pijul"},
|
||||
}
|
||||
|
||||
var cvsDummyBackend = &VCSBackend{
|
||||
Clone: func(vg *vcsGetOption) error {
|
||||
return errors.New("CVS clone is not supported")
|
||||
|
|
@ -370,6 +397,7 @@ var vcsRegistry = map[string]*VCSBackend{
|
|||
"hg": MercurialBackend,
|
||||
"mercurial": MercurialBackend,
|
||||
"darcs": DarcsBackend,
|
||||
"pijul": PijulBackend,
|
||||
"fossil": FossilBackend,
|
||||
"bzr": BazaarBackend,
|
||||
"bazaar": BazaarBackend,
|
||||
|
|
|
|||
18
vcs_test.go
18
vcs_test.go
|
|
@ -348,6 +348,24 @@ func TestVCSBackend(t *testing.T) {
|
|||
},
|
||||
expect: []string{"darcs", "pull"},
|
||||
dir: localDir,
|
||||
}, {
|
||||
name: "[pijul] clone",
|
||||
f: func() error {
|
||||
return PijulBackend.Clone(&vcsGetOption{
|
||||
url: remoteDummyURL,
|
||||
dir: localDir,
|
||||
})
|
||||
},
|
||||
expect: []string{"pijul", "clone", remoteDummyURL.String(), localDir},
|
||||
}, {
|
||||
name: "[pijul] update",
|
||||
f: func() error {
|
||||
return PijulBackend.Update(&vcsGetOption{
|
||||
dir: localDir,
|
||||
})
|
||||
},
|
||||
expect: []string{"pijul", "pull"},
|
||||
dir: localDir,
|
||||
}, {
|
||||
name: "[bzr] clone",
|
||||
f: func() error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue