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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: firstsun-dev/general-workflows/.github/workflows/obsidian-plugin-ci.yml@main
with:
plugin-id: "git-file-sync"
skip-sonar: ${{ secrets.SONAR_TOKEN == '' || vars.ENABLE_CI_SONAR != 'true' }}
skip-sonar: ${{ vars.ENABLE_CI_SONAR != 'true' }}
secrets:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5 changes: 5 additions & 0 deletions eslint.config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tseslint from 'typescript-eslint';
import obsidianmd from "eslint-plugin-obsidianmd";
import sonarjs from "eslint-plugin-sonarjs";
import globals from "globals";
import { globalIgnores } from "eslint/config";

Expand All @@ -22,6 +23,10 @@ export default tseslint.config(
},
},
...obsidianmd.configs.recommended,
{
files: ["src/**/*.ts", "src/**/*.tsx"],
...sonarjs.configs.recommended,
},
globalIgnores([
"node_modules",
"dist",
Expand Down
178 changes: 175 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"conventional-changelog-conventionalcommits": "^9.3.1",
"esbuild": "0.28.0",
"eslint-plugin-obsidianmd": "0.1.9",
"eslint-plugin-sonarjs": "^4.0.3",
"globals": "14.0.0",
"husky": "^9.1.7",
"jiti": "2.6.1",
Expand All @@ -46,4 +47,3 @@
"obsidian": "latest"
}
}

22 changes: 22 additions & 0 deletions ruleset_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "master",
"enforcement": "active",
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "required_status_checks",
"parameters": {
"strict_required_status_checks_policy": true,
"required_status_checks": [
{ "context": "CI / Lint" },
{ "context": "CI / Test (Node 22)" }
]
}
}
]
}
25 changes: 8 additions & 17 deletions src/logic/gitignore-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,18 @@ export class GitignoreManager {
* Checks if a given file path should be ignored based on loaded .gitignore rules.
*/
isIgnored(filePath: string): boolean {
// Path relative to Git Root
const fullPath = this.rootPath ? `${this.rootPath}/${filePath}` : filePath;

// Iterate through all loaded .gitignore files.
for (const [dirPath, ig] of this.ignoreMap.entries()) {
if (dirPath === '') {
// Root .gitignore applies to everything (test against fullPath)
if (ig.ignores(fullPath)) {
return true;
}
} else {
// Subdirectory .gitignore
// Check if the file is inside this directory (dirPath is relative to git root)
const prefix = dirPath + '/';
if (fullPath.startsWith(prefix)) {
// Extract the path relative to the directory containing .gitignore
const relativePath = fullPath.substring(prefix.length);
if (ig.ignores(relativePath)) {
return true;
}
}
if (ig.ignores(fullPath)) return true;
continue;
}

const prefix = dirPath + '/';
if (fullPath.startsWith(prefix)) {
const relativePath = fullPath.substring(prefix.length);
if (ig.ignores(relativePath)) return true;
}
}
return false;
Expand Down
Loading
Loading