diff --git a/.gitignore b/.gitignore index 04f05e1..2752c15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ -client -server -!client/ -!server/ +web/landing/www/binaries/hishtory-linux diff --git a/Makefile b/Makefile index ffcaa6d..79ac57c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ test: HISHTORY_TEST=1 go test -p 1 ./... build-binary: - go build -o web/landing/www/binaries/hishtory-linux -ldflags "-X main.GitCommit=`git rev-list -1 HEAD`" client/client.go + go build -trimpath -o web/landing/www/binaries/hishtory-linux -ldflags "-X main.GitCommit=`git rev-list -1 HEAD`" client/client.go build-static: build-binary docker build -t gcr.io/dworken-k8s/hishtory-static -f web/caddy/Dockerfile . diff --git a/client/client.go b/client/client.go index af9ec37..7492bd2 100644 --- a/client/client.go +++ b/client/client.go @@ -152,7 +152,7 @@ func export() { lib.CheckFatalError(retrieveAdditionalEntriesFromRemote(db)) data, err := shared.Search(db, "", 0) lib.CheckFatalError(err) - for _, entry := range data { - fmt.Println(entry) + for i := len(data)-1; i >= 0; i-- { + fmt.Println(data[i].Command) } } diff --git a/client/client_test.go b/client/client_test.go index 2be43aa..7aef4ba 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -24,7 +24,11 @@ func RunInteractiveBashCommands(t *testing.T, script string) string { var err bytes.Buffer cmd.Stderr = &err shared.CheckWithInfo(t, cmd.Run(), out.String()+err.String()) - return out.String() + outStr := out.String() + if strings.Contains(outStr, "hishtory fatal error:") { + t.Fatalf("Ran command, but hishtory had a fatal error! out=%#v", outStr) + } + return outStr } func TestIntegration(t *testing.T) { @@ -150,6 +154,12 @@ func TestIntegrationWithNewDevice(t *testing.T) { if !strings.Contains(out, "othercomputer") { t.Fatalf("hishtory query doesn't contain cmd run on another machine! out=%#v", out) } + + // Finally, test the export command + out = RunInteractiveBashCommands(t, `hishtory export`) + if out != fmt.Sprintf("/tmp/client install\n/tmp/client install\nhishtory status\nhishtory query\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nhishtory query\nhishtory query foo\n/tmp/client install %s\nhishtory query\necho mynewcommand\nhishtory query\nhishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\n", userSecret, userSecret) { + t.Fatalf("hishtory export had unexpected output! out=%#v", out) + } } func testIntegration(t *testing.T) string { @@ -233,4 +243,3 @@ func testIntegration(t *testing.T) string { return userSecret } -// TODO(ddworken): Test export diff --git a/hishtory b/hishtory deleted file mode 100755 index a123e59..0000000 Binary files a/hishtory and /dev/null differ diff --git a/web/landing/www/binaries/hishtory-linux b/web/landing/www/binaries/hishtory-linux deleted file mode 100755 index b67eeec..0000000 Binary files a/web/landing/www/binaries/hishtory-linux and /dev/null differ