Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit b9e64a5

Browse files
committed
It works!
Change-Id: If54d2ff362aca39cb92619418a31e23aa8ecb367
1 parent d4f57e8 commit b9e64a5

File tree

7 files changed

+586
-37
lines changed

7 files changed

+586
-37
lines changed

cmd/coder/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import (
55
"net/http"
66
_ "net/http/pprof"
77
"os"
8+
"path/filepath"
89

910
"github.com/spf13/pflag"
1011

12+
"github.com/mutagen-io/mutagen/pkg/command/mutagen"
1113
"go.coder.com/cli"
1214
)
1315

@@ -39,6 +41,7 @@ func (r *rootCmd) Subcommands() []cli.Command {
3941
&urlsCmd{},
4042
&versionCmd{},
4143
&configSSHCmd{},
44+
&mutagenCmd{},
4245
}
4346
}
4447

@@ -48,5 +51,9 @@ func main() {
4851
log.Println(http.ListenAndServe("localhost:6060", nil))
4952
}()
5053
}
54+
if filepath.Base(os.Args[0]) == "mutagen" {
55+
mutagen.Main()
56+
return
57+
}
5158
cli.RunRoot(&rootCmd{})
5259
}

cmd/coder/mutagen.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"github.com/mutagen-io/mutagen/pkg/command/mutagen"
5+
"github.com/spf13/pflag"
6+
"go.coder.com/cli"
7+
"os"
8+
)
9+
10+
type mutagenCmd struct {
11+
12+
}
13+
14+
func (m *mutagenCmd) Spec() cli.CommandSpec {
15+
return cli.CommandSpec{
16+
Name: "mutagen",
17+
Usage: "[mutagen args...]",
18+
Desc: "call the embedded mutagen",
19+
RawArgs: true,
20+
}
21+
}
22+
23+
func (m *mutagenCmd) Run(_ *pflag.FlagSet) {
24+
// Pop out first argument (coder) so mutagen thinks its mutagen.
25+
copy(os.Args, os.Args[1:])
26+
os.Args = os.Args[:len(os.Args)-1]
27+
mutagen.Main()
28+
}
29+

cmd/coder/sync.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"os"
54
"path/filepath"
65
"strings"
76

@@ -40,14 +39,6 @@ func (cmd *syncCmd) Run(fl *pflag.FlagSet) {
4039

4140
entClient := requireAuth()
4241

43-
info, err := os.Stat(local)
44-
if err != nil {
45-
flog.Fatal("%v", err)
46-
}
47-
if !info.IsDir() {
48-
flog.Fatal("%s must be a directory", local)
49-
}
50-
5142
remoteTokens := strings.SplitN(remote, ":", 2)
5243
if len(remoteTokens) != 2 {
5344
flog.Fatal("remote misformatted")
@@ -64,17 +55,18 @@ func (cmd *syncCmd) Run(fl *pflag.FlagSet) {
6455
flog.Fatal("make abs path out of %v: %v", local, absLocal)
6556
}
6657

67-
s := sync.Sync{
68-
Init: cmd.init,
69-
Env: env,
70-
RemoteDir: remoteDir,
71-
LocalDir: absLocal,
72-
Client: entClient,
58+
s := sync.Syncer{
59+
Environment: env,
60+
RemoteDir: remoteDir,
61+
LocalDir: absLocal,
7362
}
74-
for err == nil || err == sync.ErrRestartSync {
75-
err = s.Run()
63+
64+
err = s.Create()
65+
if err != nil {
66+
flog.Fatal("%v", err)
7667
}
7768

69+
err = s.Monitor()
7870
if err != nil {
7971
flog.Fatal("%v", err)
8072
}

go.mod

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,33 @@ go 1.14
44

55
require (
66
cdr.dev/wsep v0.0.0-20200616212001-0613cfe9a4ac
7-
github.com/fatih/color v1.9.0 // indirect
8-
github.com/gorilla/websocket v1.4.1
7+
github.com/bmatcuk/doublestar v1.3.1 // indirect
8+
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
99
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
1010
github.com/klauspost/compress v1.10.8 // indirect
11-
github.com/mattn/go-colorable v0.1.6 // indirect
11+
github.com/lucas-clemente/quic-go v0.17.2 // indirect
12+
github.com/marten-seemann/qtls v0.10.0 // indirect
13+
github.com/mattn/go-colorable v0.1.7 // indirect
14+
github.com/mutagen-io/mutagen v0.12.0-alpha1
15+
github.com/pion/sdp/v2 v2.3.9 // indirect
16+
github.com/pion/stun v0.3.5 // indirect
17+
github.com/pion/webrtc/v2 v2.2.17 // indirect
1218
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
13-
github.com/rjeczalik/notify v0.9.2
1419
github.com/spf13/pflag v1.0.5
1520
go.coder.com/cli v0.4.0
1621
go.coder.com/flog v0.0.0-20190906214207-47dd47ea0512
17-
golang.org/x/crypto v0.0.0-20200422194213-44a606286825
18-
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
19-
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1
22+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
23+
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
24+
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
25+
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
26+
golang.org/x/text v0.3.3 // indirect
2027
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
2128
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
29+
google.golang.org/genproto v0.0.0-20200702021140-07506425bd67 // indirect
30+
google.golang.org/grpc v1.30.0 // indirect
31+
google.golang.org/protobuf v1.25.0 // indirect
32+
k8s.io/apimachinery v0.18.5 // indirect
2233
nhooyr.io/websocket v1.8.6
2334
)
35+
36+
replace github.com/mutagen-io/mutagen => github.com/cdr/mutagen v0.12.0-alpha1.0.20200702032615-836681a5c914

0 commit comments

Comments
 (0)