Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gittensory-mcp/lib/local-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export function isTestFile(file) {
}

export function isCodeFile(file) {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy)$/i.test(file) && !isTestFile(file);
}

function numberValue(value) {
Expand Down
7 changes: 5 additions & 2 deletions packages/gittensory-mcp/scripts/gittensor-score-preview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ function isTestFile(file) {
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file)
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file) ||
// JVM/.NET/Swift PascalCase test-class suffix (case-sensitive, matching the
// signal classifiers) so C#/Swift/Groovy tests aren't counted as source.
/(^|\/)\w*(Tests?|Spec)\.(java|kt|kts|scala|cs|swift|groovy)$/.test(file)
);
}

function isCodeFile(file) {
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy)$/i.test(file) && !isTestFile(file);
}

function lineCount(file) {
Expand Down
10 changes: 9 additions & 1 deletion packages/gittensory-mcp/scripts/gittensor-score-preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@

import json
import os
import re
import sys
from pathlib import Path

# JVM/.NET/Swift PascalCase test-class suffix (case-sensitive, on the original
# path) so C#/Swift/Groovy tests aren't counted as source once their extensions
# are recognized as code. Matches the signal classifiers' isTestPath rule.
_JVM_TEST_SUFFIX_RE = re.compile(r"(?:Tests?|Spec)\.(?:java|kt|kts|scala|cs|swift|groovy)$")


def is_test_file(path: str) -> bool:
lowered = path.lower()
Expand Down Expand Up @@ -40,6 +46,8 @@ def is_test_file(path: str) -> bool:
".spec.rb",
".spec.rs",
)
if _JVM_TEST_SUFFIX_RE.search(path):
return True
return any(token in lowered for token in patterns) or any(basename.endswith(suffix) for suffix in ("_test.go", "_test.py", "_test.rb"))


Expand Down Expand Up @@ -152,7 +160,7 @@ def metadata_fallback(metadata: dict) -> dict:
lines = max(int(entry.get("additions") or 0) + int(entry.get("deletions") or 0), 0)
if is_test_file(path):
tests += lines
elif path.endswith((".ts", ".tsx", ".js", ".jsx", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql")):
elif path.endswith((".ts", ".tsx", ".js", ".jsx", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql", ".cs", ".swift", ".groovy")):
source += lines
else:
non_code += lines
Expand Down
8 changes: 7 additions & 1 deletion src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5515,7 +5515,13 @@ function sanitizeOutcomeDimensionKey(key: string): string {
}

function isCodeFile(file: string): boolean {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
// Mirrors isCodeFile in local-branch.ts — kept in sync (cs/swift/groovy added
// so C#/Swift/Groovy source counts as code, matching the test conventions
// isTestPath already recognizes).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy)$/i.test(file) &&
!isTestFile(file)
);
}

function isTestFile(file: string): boolean {
Expand Down
9 changes: 8 additions & 1 deletion src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,14 @@ export function isTestFile(file: string): boolean {
}

export function isCodeFile(file: string): boolean {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
// cs/swift/groovy round out the JVM/.NET/Swift set: isTestPath already
// recognizes their `SomethingTest(s)`/`Spec` test files, so their source must
// count as code too — otherwise a C#/Swift/Groovy source file is neither test
// nor code in the local scorer.
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy)$/i.test(file) &&
!isTestFile(file)
);
}

function sameRepo(left: string, right: string): boolean {
Expand Down
8 changes: 8 additions & 0 deletions test/unit/local-branch-file-classifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ describe("isCodeFile", () => {
"src/config.mts",
"src/setup.cts",
"helper_test.ts",
// C#/Swift/Groovy source — their test files are already recognized by
// isTestPath, so their source must count as code too.
"Api/Controllers/UserController.cs",
"Sources/App/Router.swift",
"src/main/groovy/Pipeline.groovy",
]) {
expect(isCodeFile(path)).toBe(true);
}
Expand All @@ -133,6 +138,9 @@ describe("isCodeFile", () => {
// module-extension e2e tests must not count as code
"e2e/checkout.cy.mts",
"e2e/flow.e2e.mjs",
// C#/Swift test files carry a code extension but are tests, not code.
"Services/AccountTests.cs",
"AppTests/LoginTests.swift",
]) {
expect(isCodeFile(path)).toBe(false);
}
Expand Down
Loading