Skip to content

Commit

Permalink
Merge pull request #1049 from wakatime/develop
Browse files Browse the repository at this point in the history
Release v1.91.1
  • Loading branch information
gandarez committed Jun 9, 2024
2 parents cf90685 + 6e4e386 commit 1495e44
Show file tree
Hide file tree
Showing 36 changed files with 166 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ jobs:
name: Build binary
env:
VERSION: ${{ env.TEST_VERSION }}
run: make build-darwin-amd64
run: make build-darwin-arm64
-
name: Integration tests
run: make test-integration
Expand Down
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ run:
timeout: 5m
build-tags:
- integration
skip-dirs:
- "testdata"
skip-files:
- pkg/file/file_windows.go
linters:
enable:
- bodyclose
Expand Down Expand Up @@ -60,6 +56,10 @@ linters-settings:
- name: var-naming
issues:
exclude-use-default: false
exclude-dirs:
- testdata
exclude-files:
- pkg/file/file_windows.go
exclude-rules:
- path: _test\.go
linters:
Expand Down
6 changes: 4 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Here's an example `$WAKATIME_HOME/.wakatime.cfg` config file with all available
[settings]
debug = false
api_key = your-api-key
api_key_vault_cmd = any shell command to get your api key from vault
api_key_vault_cmd = command arg arg ... (space-separated, no shell syntax)
api_url = https://api.wakatime.com/api/v1
hide_file_names = false
hide_project_names = false
Expand All @@ -64,6 +64,7 @@ hostname = machinename
log_file =
import_cfg = /path/to/another/wakatime.cfg
metrics = true
guess_language = true

[projectmap]
projects/foo = new project name
Expand All @@ -88,7 +89,7 @@ some/submodule/name = new project name
| --- | --- | --- | --- |
| debug | Turns on debug messages in log file. | _bool_ | `false` |
| api_key | Your wakatime api key. | _string_ | |
| api_key_vault_cmd | Any shell command to get your api key from vault. | _string_ | |
| api_key_vault_cmd | A command to get your api key, perhaps from some sort of secure vault. Actually a space-separated list of an executable and its arguments. Executables in PATH can be referred to by their basenames. Shell syntax not supported. | _string_ | |
| api_url | The WakaTime API base url. | _string_ | <https://api.wakatime.com/api/v1> |
| hide_file_names | Obfuscate filenames. Will not send file names to api. | _bool_;_list_ | `false` |
| hide_project_names | Obfuscate project names. When a project folder is detected instead of using the folder name as the project, a `.wakatime-project file` is created with a random project name. | _bool_;_list_ | `false` |
Expand All @@ -110,6 +111,7 @@ some/submodule/name = new project name
| log_file | Optional log file path. | _filepath_ | `~/.wakatime/wakatime.log` |
| import_cfg | Optional path to another wakatime.cfg file to import. If set it will overwrite values loaded from $WAKATIME_HOME/.wakatime.cfg file. | _filepath_ | |
| metrics | When set, collects metrics usage in '~/.wakatime/metrics' folder. For further reference visit <https://go.dev/blog/pprof>. | _bool_ | `false` |
| guess_language | When `true`, enables detecting programming language from file contents. | _bool_ | `false` |

### Project Map Section

Expand Down
7 changes: 1 addition & 6 deletions cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ func newClient(params paramscmd.API, opts ...api.Option) (*api.Client, error) {

opts = append(opts, withSSLCert)
} else if !params.DisableSSLVerify {
withSSLCert, err := api.WithSSLCertPool(api.CACerts())
if err != nil {
return nil, fmt.Errorf("failed to set up ssl cert pool option on api client: %s", err)
}

opts = append(opts, withSSLCert)
opts = append(opts, api.WithSSLCertPool(api.CACerts()))
}

if params.ProxyURL != "" {
Expand Down
9 changes: 6 additions & 3 deletions cmd/fileexperts/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ func TestFileExperts_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -172,8 +173,9 @@ func TestFileExperts_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -205,8 +207,9 @@ func TestFileExperts_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
13 changes: 5 additions & 8 deletions cmd/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestSendHeartbeats_WithFiltering_Exclude(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)

numCalls++
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestSendHeartbeats_ExtraHeartbeats_Sanitize(t *testing.T) {
numCalls int
)

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
// send response
w.WriteHeader(http.StatusCreated)

Expand Down Expand Up @@ -724,10 +724,9 @@ func TestSendHeartbeats_ErrAuth_UnsetAPIKey(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusCreated)
})

Expand Down Expand Up @@ -760,10 +759,9 @@ func TestSendHeartbeats_ErrBackoff(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -824,10 +822,9 @@ func TestSendHeartbeats_ErrBackoff_Verbose(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/params/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,8 @@ func TestLoad_API_APIKeyInvalid(t *testing.T) {
require.Error(t, err)

var errauth api.ErrAuth
assert.ErrorAs(t, err, &errauth)

assert.ErrorAs(t, err, &errauth)
assert.EqualError(t, errauth, "invalid api key format")
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewRootCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "wakatime-cli",
Short: "Command line interface used by all WakaTime text editor plugins.",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
Run(cmd, v)
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/run_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
func TestRunCmd(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.Success, nil
})

Expand All @@ -35,7 +35,7 @@ func TestRunCmd(t *testing.T) {
func TestRunCmd_Err(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestRunCmd_ErrOfflineEnqueue(t *testing.T) {
v.Set("key", "00000000-0000-4000-8000-000000000000")
v.Set("plugin", "vim")

ret := runCmd(v, true, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, true, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down
18 changes: 9 additions & 9 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestRunCmd_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -76,7 +76,7 @@ func TestRunCmd_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -149,7 +149,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -198,7 +198,7 @@ func TestRunCmd_SendDiagnostics_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestRunCmd_SendDiagnostics_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestRunCmd_SendDiagnostics_NoLogs_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestRunCmd_SendDiagnostics_WakaError(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, offline.ErrOpenDB{Err: errors.New("fail")}
}
Expand Down Expand Up @@ -630,7 +630,7 @@ func TestRunCmdWithOfflineSync(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 0, nil
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/today/today_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func TestToday_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -104,8 +105,9 @@ func TestToday_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -137,8 +139,9 @@ func TestToday_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
9 changes: 6 additions & 3 deletions cmd/todaygoal/todaygoal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func TestGoal_ErrApi(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -111,8 +112,9 @@ func TestGoal_ErrAuth(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -146,8 +148,9 @@ func TestGoal_ErrBadRequest(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/wakatime/wakatime-cli

go 1.22
go 1.22.4

require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down Expand Up @@ -433,8 +431,6 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
Loading

0 comments on commit 1495e44

Please sign in to comment.