Skip to content

Commit dafa59d

Browse files
committed
Support pijul
1 parent 7163e61 commit dafa59d

File tree

7 files changed

+80
-0
lines changed

7 files changed

+80
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,33 @@ 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+
if vg.branch != "" {
304+
return errors.New("pijul does not support branch")
305+
}
306+
307+
dir, _ := filepath.Split(vg.dir)
308+
err := os.MkdirAll(dir, 0755)
309+
if err != nil {
310+
return err
311+
}
312+
313+
args := []string{"clone"}
314+
args = append(args, vg.url.String(), vg.dir)
315+
316+
return run(vg.silent)("pijul", args...)
317+
},
318+
Update: func(vg *vcsGetOption) error {
319+
return runInDir(vg.silent)(vg.dir, "pijul", "pull")
320+
},
321+
Init: func(dir string) error {
322+
return cmdutil.RunInDir(dir, "pijul", "init")
323+
},
324+
Contents: []string{".pijul"},
325+
}
326+
300327
var cvsDummyBackend = &VCSBackend{
301328
Clone: func(vg *vcsGetOption) error {
302329
return errors.New("CVS clone is not supported")
@@ -370,6 +397,7 @@ var vcsRegistry = map[string]*VCSBackend{
370397
"hg": MercurialBackend,
371398
"mercurial": MercurialBackend,
372399
"darcs": DarcsBackend,
400+
"pijul": PijulBackend,
373401
"fossil": FossilBackend,
374402
"bzr": BazaarBackend,
375403
"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)