Skip to content

Commit

Permalink
Merge pull request #1098 from wakatime/develop
Browse files Browse the repository at this point in the history
Release v1.99.1
  • Loading branch information
alanhamlett authored Sep 17, 2024
2 parents f480c03 + 6aa54e7 commit 8af2b7b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 19 deletions.
6 changes: 3 additions & 3 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ some/submodule/name = new project name

### Project Map Section

A key value pair list separated by new line. Use when a project should be renamed to another when sent to the API.
A key value pair list separated by new line, where the value before equal sign is the regex pattern and the latter is the override project name. Use when a project should be renamed to another when sent to the API. The order of the project map is important, the first match is used. Do not add any leading space before the regex pattern.

```ini
[projectmap]
Expand All @@ -126,7 +126,7 @@ projects/foo = new project name

### Project Api Key Section

A key value pair list separated by new line. Use when a project should be sent using another api key other than the default on `settings.api_key`.
A key value pair list separated by new line, where the value before equal sign is the regex pattern and the latter is the override api key. Use when a project should be sent using another api key other than the default on `settings.api_key`. The order of the project api key is important, the first match is used. Do not add any leading space before the regex pattern.

```ini
[project_api_key]
Expand All @@ -148,7 +148,7 @@ However, if an api key exists in your `~/.wakatime.cfg` file then it takes prece

### Git Submodule Project Map Section

A key value pair list separated by new line. Use when a submodule project should be renamed to another when sent to the API.
A key value pair list separated by new line, where the value before equal sign is the regex pattern and the latter is the override project name for submodule. Use when a submodule project should be renamed to another when sent to the API. The order of the git submodule project map is important, the first match is used. Do not add any leading space before the regex pattern.

```ini
[git_submodule_projectmap]
Expand Down
27 changes: 22 additions & 5 deletions cmd/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func TestSendHeartbeats(t *testing.T) {
projectFolder, err := filepath.Abs("../..")
require.NoError(t, err)

tmpFile, err := os.CreateTemp(t.TempDir(), "wakatime-config")
require.NoError(t, err)

subfolders := project.CountSlashesInProjectFolder(projectFolder)

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -96,6 +99,7 @@ func TestSendHeartbeats(t *testing.T) {
v := viper.New()
v.SetDefault("sync-offline-activity", 1000)
v.Set("api-url", testServerURL)
v.Set("config", tmpFile.Name())
v.Set("category", "debugging")
v.Set("cursorpos", 42)
v.Set("entity", "testdata/main.go")
Expand All @@ -122,6 +126,10 @@ func TestSendHeartbeats(t *testing.T) {
}

func TestSendHeartbeats_RateLimited(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping because OS is windows.")
}

resetSingleton(t)

testServerURL, router, tearDown := setupTestServer()
Expand All @@ -137,7 +145,10 @@ func TestSendHeartbeats_RateLimited(t *testing.T) {
numCalls++
})

tmpFile, err := os.CreateTemp(t.TempDir(), "wakatime-internal-config")
tmpFile, err := os.CreateTemp(t.TempDir(), "wakatime-config")
require.NoError(t, err)

tmpFileInternal, err := os.CreateTemp(t.TempDir(), "wakatime-internal-config")
require.NoError(t, err)

offlineQueueFile, err := os.CreateTemp(t.TempDir(), "offline-queue-file")
Expand All @@ -162,7 +173,8 @@ func TestSendHeartbeats_RateLimited(t *testing.T) {
v.Set("timeout", 5)
v.Set("write", true)
v.Set("heartbeat-rate-limit-seconds", 500)
v.Set("internal-config", tmpFile.Name())
v.Set("config", tmpFile.Name())
v.Set("internal-config", tmpFileInternal.Name())
v.Set("offline-queue-file", offlineQueueFile.Name())
v.Set("internal.heartbeats_last_sent_at", time.Now().Add(-time.Minute).Format(time.RFC3339))

Expand Down Expand Up @@ -1189,13 +1201,18 @@ func TestResetRateLimit(t *testing.T) {

defer tmpFile.Close()

tmpFileInternal, err := os.CreateTemp(t.TempDir(), "wakatime-internal")
require.NoError(t, err)

defer tmpFileInternal.Close()

v := viper.New()
v.Set("config", tmpFile.Name())
v.Set("internal-config", tmpFile.Name())
v.Set("config", tmpFileInternal.Name())
v.Set("internal-config", tmpFileInternal.Name())

writer, err := ini.NewWriter(v, func(vp *viper.Viper) (string, error) {
assert.Equal(t, v, vp)
return tmpFile.Name(), nil
return tmpFileInternal.Name(), nil
})
require.NoError(t, err)

Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.5
require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
github.com/alecthomas/assert v1.0.0
github.com/alecthomas/chroma/v2 v2.9.1
github.com/alecthomas/chroma/v2 v2.10.0
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
github.com/dlclark/regexp2 v1.10.0
github.com/gandarez/go-olson-timezone v0.1.0
Expand All @@ -30,7 +30,7 @@ require (

require (
github.com/alecthomas/colour v0.1.0 // indirect
github.com/alecthomas/repr v0.2.0 // indirect
github.com/alecthomas/repr v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -55,6 +55,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/alecthomas/chroma/v2 => github.com/gandarez/chroma/v2 v2.9.1-wakatime.1
// replace github.com/alecthomas/chroma/v2 => github.com/gandarez/chroma/v2 v2.9.1-wakatime.1
// replace github.com/alecthomas/chroma/v2 => /Users/gandarez/development/git/gandarez/chroma

replace github.com/matishsiao/goInfo => github.com/wakatime/goInfo v0.1.0-wakatime.8
replace github.com/matishsiao/goInfo => github.com/wakatime/goInfo v0.1.0-wakatime.9
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI
github.com/alecthomas/assert v1.0.0/go.mod h1:va/d2JC+M7F6s+80kl/R3G7FUiW6JzUO+hPhLyJ36ZY=
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/chroma/v2 v2.10.0 h1:T2iQOCCt4pRmRMfL55gTodMtc7cU0y7lc1Jb8/mK/64=
github.com/alecthomas/chroma/v2 v2.10.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8=
github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down Expand Up @@ -75,8 +77,6 @@ github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0X
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gandarez/chroma/v2 v2.9.1-wakatime.1 h1:czvEuO+JRT4y2HTTh0REP0p0ebfleH6eY70UI0WF4OQ=
github.com/gandarez/chroma/v2 v2.9.1-wakatime.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
github.com/gandarez/go-olson-timezone v0.1.0 h1:cDRlHKQE0uC3mJNZyKoQIpAuvQtV8KXwIVj8bDEEyuo=
github.com/gandarez/go-olson-timezone v0.1.0/go.mod h1:+yV/cYNjgs2JqdGShznAD4R13r8lKMGR2XlWAJqa5Yo=
github.com/gandarez/go-realpath v1.0.0 h1:fhQBRDshH/MZNmDLWM9vbBameK2fxyLr+ctqkRwbHEU=
Expand Down Expand Up @@ -270,6 +270,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/wakatime/goInfo v0.1.0-wakatime.8 h1:MgyeRnCkynEmUxLKXnYUAP5Dd+vhKxhqg6Nx1PdAZy4=
github.com/wakatime/goInfo v0.1.0-wakatime.8/go.mod h1:aEt7p9Rvh67BYApmZwNDPpgircTO2kgdmDUoF/1QmwA=
github.com/wakatime/goInfo v0.1.0-wakatime.9 h1:QkFBcdCcUwFb2CxacFdt4I4aVPcJRY7nXh0sq1gqu3o=
github.com/wakatime/goInfo v0.1.0-wakatime.9/go.mod h1:aEt7p9Rvh67BYApmZwNDPpgircTO2kgdmDUoF/1QmwA=
github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ=
github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
6 changes: 3 additions & 3 deletions pkg/deps/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func (p *ParserJava) processToken(token chroma.Token) {
p.processNameAttribute(token.Value)
case chroma.NameNamespace:
p.processNameNamespace(token.Value)
case chroma.Operator:
p.processOperator(token.Value)
case chroma.Punctuation:
p.processPunctuation(token.Value)
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ func (p *ParserJava) processNameNamespace(value string) {
}
}

func (p *ParserJava) processOperator(value string) {
func (p *ParserJava) processPunctuation(value string) {
if value == ";" {
p.State = StateJavaImportFinished
p.processKeywordNamespace(p.Buffer)
Expand Down
14 changes: 14 additions & 0 deletions pkg/heartbeat/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ const (
LanguageCSV
// LanguageCUDA represents the CUDA programming language.
LanguageCUDA
// LanguageCUE represents the CUE programming language.
LanguageCUE
// LanguagecURLConfig represents the cURLConfig programming language.
LanguagecURLConfig
// LanguageCVS represents the CVS programming language.
Expand Down Expand Up @@ -1061,6 +1063,8 @@ const (
LanguagePromQL
// LanguageProtocolBuffer represents the ProtocolBuffer programming language.
LanguageProtocolBuffer
// LanguagePRQL represents the PRQL programming language.
LanguagePRQL
// LanguagePSL represents the Property Specification Language programming language.
LanguagePSL
// LanguagePsyShPHP represents the PHPPsySH programming language.
Expand Down Expand Up @@ -1728,6 +1732,7 @@ const (
languageCSSStr = "CSS"
languageCSVStr = "CSV"
languageCUDAStr = "Cuda"
languageCUEStr = "CUE"
languagecURLConfigStr = "cURL Config"
languageCVSStr = "CVS"
languageCWebStr = "CWeb"
Expand Down Expand Up @@ -2098,6 +2103,7 @@ const (
languagePrologStr = "Prolog"
languagePromQLStr = "PromQL"
languageProtocolBufferStr = "Protocol Buffer"
languagePRQLStr = "PRQL"
languagePSLStr = "Property Specification Language"
languagePsyShPHPStr = "PsySH console session for PHP"
languagePugStr = "Pug"
Expand Down Expand Up @@ -2723,6 +2729,8 @@ func ParseLanguage(s string) (Language, bool) {
return LanguageCSV, true
case normalizeString(languageCUDAStr):
return LanguageCUDA, true
case normalizeString(languageCUEStr):
return LanguageCUE, true
case normalizeString(languagecURLConfigStr):
return LanguagecURLConfig, true
case normalizeString(languageCVSStr):
Expand Down Expand Up @@ -3463,6 +3471,8 @@ func ParseLanguage(s string) (Language, bool) {
return LanguagePromQL, true
case normalizeString(languageProtocolBufferStr):
return LanguageProtocolBuffer, true
case normalizeString(languagePRQLStr):
return LanguagePRQL, true
case normalizeString(languagePSLStr):
return LanguagePSL, true
case normalizeString(languagePsyShPHPStr):
Expand Down Expand Up @@ -4411,6 +4421,8 @@ func (l Language) String() string {
return languageCSVStr
case LanguageCUDA:
return languageCUDAStr
case LanguageCUE:
return languageCUEStr
case LanguagecURLConfig:
return languagecURLConfigStr
case LanguageCVS:
Expand Down Expand Up @@ -5149,6 +5161,8 @@ func (l Language) String() string {
return languagePromQLStr
case LanguageProtocolBuffer:
return languageProtocolBufferStr
case LanguagePRQL:
return languagePRQLStr
case LanguagePsyShPHP:
return languagePsyShPHPStr
case LanguagePug:
Expand Down
2 changes: 2 additions & 0 deletions pkg/heartbeat/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func languageTests() map[string]heartbeat.Language {
"CSS": heartbeat.LanguageCSS,
"CSV": heartbeat.LanguageCSV,
"Cuda": heartbeat.LanguageCUDA,
"CUE": heartbeat.LanguageCUE,
"cURL Config": heartbeat.LanguagecURLConfig,
"CVS": heartbeat.LanguageCVS,
"CWeb": heartbeat.LanguageCWeb,
Expand Down Expand Up @@ -537,6 +538,7 @@ func languageTests() map[string]heartbeat.Language {
"PromQL": heartbeat.LanguagePromQL,
"Property Specification Language": heartbeat.LanguagePSL,
"Protocol Buffer": heartbeat.LanguageProtocolBuffer,
"PRQL": heartbeat.LanguagePRQL,
"PsySH console session for PHP": heartbeat.LanguagePsyShPHP,
"Pug": heartbeat.LanguagePug,
"Puppet": heartbeat.LanguagePuppet,
Expand Down

0 comments on commit 8af2b7b

Please sign in to comment.