Skip to content

Commit 8f42cc3

Browse files
authored
Merge pull request #372 from yoichi/pijul
Support pijul
2 parents 7163e61 + 026adc2 commit 8f42cc3

File tree

7 files changed

+79
-0
lines changed

7 files changed

+79
-0
lines changed

cmd_create_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func TestDoCreate(t *testing.T) {
7272
input: []string{"create", "--vcs=darcs", "motemen/ghq-darcs"},
7373
want: []string{"darcs", "init"},
7474
wantDir: filepath.Join(tmpd, "github.com/motemen/ghq-darcs"),
75+
}, {
76+
name: "Pijul",
77+
input: []string{"create", "--vcs=pijul", "motemen/ghq-pijul"},
78+
want: []string{"pijul", "init"},
79+
wantDir: filepath.Join(tmpd, "github.com/motemen/ghq-pijul"),
7580
}, {
7681
name: "Bazzar",
7782
input: []string{"create", "--vcs=bzr", "motemen/ghq-bzr"},

local_repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ var vcsContentsMap = map[string]*VCSBackend{
208208
".hg": MercurialBackend,
209209
".svn": SubversionBackend,
210210
"_darcs": DarcsBackend,
211+
".pijul": PijulBackend,
211212
".bzr": BazaarBackend,
212213
".fslckout": FossilBackend, // file
213214
"_FOSSIL_": FossilBackend, // file
@@ -219,6 +220,7 @@ var vcsContents = [...]string{
219220
".hg",
220221
".svn",
221222
"_darcs",
223+
".pijul",
222224
".bzr",
223225
".fslckout",
224226
"._FOSSIL_",

logger/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var logger = colorine.NewLogger(
1414
"hg": colorine.Verbose,
1515
"svn": colorine.Verbose,
1616
"darcs": colorine.Verbose,
17+
"pijul": colorine.Verbose,
1718
"bzr": colorine.Verbose,
1819
"fossil": colorine.Verbose,
1920
"skip": colorine.Verbose,

remote_repository.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ func (repo *DarksHubRepository) VCS() (*VCSBackend, *url.URL, error) {
9393
return DarcsBackend, repo.URL(), nil
9494
}
9595

96+
// NestPijulRepository represents the Nest repository
97+
type NestPijulRepository struct {
98+
url *url.URL
99+
}
100+
101+
// URL returns URL of the Nest repository
102+
func (repo *NestPijulRepository) URL() *url.URL {
103+
return repo.url
104+
}
105+
106+
// IsValid determine if the Nest repository is valid or not
107+
func (repo *NestPijulRepository) IsValid() bool {
108+
return strings.Count(repo.url.Path, "/") == 2
109+
}
110+
111+
// VCS returns VCSBackend of the Nest repository
112+
func (repo *NestPijulRepository) VCS() (*VCSBackend, *url.URL, error) {
113+
return PijulBackend, repo.URL(), nil
114+
}
115+
96116
// A CodeCommitRepository represents a CodeCommit repository. Implements RemoteRepository.
97117
type CodeCommitRepository struct {
98118
url *url.URL
@@ -197,6 +217,8 @@ func NewRemoteRepository(u *url.URL) (RemoteRepository, error) {
197217
return &GitHubGistRepository{u}
198218
case "hub.darcs.net":
199219
return &DarksHubRepository{u}
220+
case "nest.pijul.com":
221+
return &NestPijulRepository{u}
200222
default:
201223
return &OtherRepository{u}
202224
}

remote_repository_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func TestNewRemoteRepository(t *testing.T) {
3535
url: "http://hub.darcs.net/foo/bar",
3636
valid: true,
3737
vcsBackend: DarcsBackend,
38+
}, {
39+
url: "http://nest.pijul.com/foo/bar",
40+
valid: true,
41+
vcsBackend: PijulBackend,
3842
}, {
3943
url: "svn+ssh://example.com/proj/repo",
4044
valid: true,

vcs.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,32 @@ var DarcsBackend = &VCSBackend{
297297
Contents: []string{"_darcs"},
298298
}
299299

300+
// PijulBackend is the VCSBackend for pijul
301+
var PijulBackend = &VCSBackend{
302+
Clone: func(vg *vcsGetOption) error {
303+
dir, _ := filepath.Split(vg.dir)
304+
err := os.MkdirAll(dir, 0755)
305+
if err != nil {
306+
return err
307+
}
308+
309+
args := []string{"clone"}
310+
if vg.branch != "" {
311+
args = append(args, "--channel", vg.branch)
312+
}
313+
args = append(args, vg.url.String(), vg.dir)
314+
315+
return run(vg.silent)("pijul", args...)
316+
},
317+
Update: func(vg *vcsGetOption) error {
318+
return runInDir(vg.silent)(vg.dir, "pijul", "pull")
319+
},
320+
Init: func(dir string) error {
321+
return cmdutil.RunInDir(dir, "pijul", "init")
322+
},
323+
Contents: []string{".pijul"},
324+
}
325+
300326
var cvsDummyBackend = &VCSBackend{
301327
Clone: func(vg *vcsGetOption) error {
302328
return errors.New("CVS clone is not supported")
@@ -370,6 +396,7 @@ var vcsRegistry = map[string]*VCSBackend{
370396
"hg": MercurialBackend,
371397
"mercurial": MercurialBackend,
372398
"darcs": DarcsBackend,
399+
"pijul": PijulBackend,
373400
"fossil": FossilBackend,
374401
"bzr": BazaarBackend,
375402
"bazaar": BazaarBackend,

vcs_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,24 @@ func TestVCSBackend(t *testing.T) {
348348
},
349349
expect: []string{"darcs", "pull"},
350350
dir: localDir,
351+
}, {
352+
name: "[pijul] clone",
353+
f: func() error {
354+
return PijulBackend.Clone(&vcsGetOption{
355+
url: remoteDummyURL,
356+
dir: localDir,
357+
})
358+
},
359+
expect: []string{"pijul", "clone", remoteDummyURL.String(), localDir},
360+
}, {
361+
name: "[pijul] update",
362+
f: func() error {
363+
return PijulBackend.Update(&vcsGetOption{
364+
dir: localDir,
365+
})
366+
},
367+
expect: []string{"pijul", "pull"},
368+
dir: localDir,
351369
}, {
352370
name: "[bzr] clone",
353371
f: func() error {

0 commit comments

Comments
 (0)