Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement fallback in case git diff does not work with merge-base #3503

Merged
merged 2 commits into from
Apr 23, 2024
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
39 changes: 20 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Reporters

- Fixes
- Implement fallback in case git diff does not work with merge-base

- Doc

Expand All @@ -30,45 +31,45 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
## [v7.11.0] - 2024-04-23

- Core
- Allow to override the number of parallel cores used, with variable **PARALLEL_PROCESS_NUMBER**, by @nvuillam in https://github.com/oxsecurity/megalinter/pull/3428
- Allow to override the number of parallel cores used, with variable **PARALLEL_PROCESS_NUMBER**, by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3428>
- Upgrade base python image from 3.12.2-alpine3.19 to 3.12.3-alpine3.19
- Upgrade PHP 8.1 to 8.3 by @llaville in https://github.com/oxsecurity/megalinter/pull/3464
- Add descriptor pre / post commands, by @bdovaz in https://github.com/oxsecurity/megalinter/pull/3468
- Allow merge lists with **EXTENDS**, by @bdovaz in https://github.com/oxsecurity/megalinter/pull/3469
- Upgrade PHP 8.1 to 8.3 by @llaville in <https://github.com/oxsecurity/megalinter/pull/3464>
- Add descriptor pre / post commands, by @bdovaz in <https://github.com/oxsecurity/megalinter/pull/3468>
- Allow merge lists with **EXTENDS**, by @bdovaz in <https://github.com/oxsecurity/megalinter/pull/3469>

- Media

- New linters
- Add Kotlin detekt linter, by @enciyo in https://github.com/oxsecurity/megalinter/pull/3408
- Add Kotlin detekt linter, by @enciyo in <https://github.com/oxsecurity/megalinter/pull/3408>

- Reporters
- Add ruff sarif support, by @Skitionek in https://github.com/oxsecurity/megalinter/pull/3486
- Add ruff sarif support, by @Skitionek in <https://github.com/oxsecurity/megalinter/pull/3486>

- Fixes
- Fix listing of modified files, by @vkucera in <https://github.com/oxsecurity/megalinter/pull/3472>. Fixes <https://github.com/oxsecurity/megalinter/issues/2125>.
- Fix conflict between prettier and yamllint about spaces, by @apeyrat in https://github.com/oxsecurity/megalinter/pull/3426
- Ensure [trufflehog](https://github.com/trufflesecurity/trufflehog) does not auto-update itself, by @wandering-tales in https://github.com/oxsecurity/megalinter/pull/3430
- Salesforce linters: use sf + default Flow Scanner rules, by @nvuillam in https://github.com/oxsecurity/megalinter/pull/3435
- Fix conflict between prettier and yamllint about spaces, by @apeyrat in <https://github.com/oxsecurity/megalinter/pull/3426>
- Ensure [trufflehog](https://github.com/trufflesecurity/trufflehog) does not auto-update itself, by @wandering-tales in <https://github.com/oxsecurity/megalinter/pull/3430>
- Salesforce linters: use sf + default Flow Scanner rules, by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3435>
- Disable JSON_ESLINT_PLUGIN_JSONC until <https://github.com/ota-meshi/eslint-plugin-jsonc/issues/328> is fixed
- Upgrade tar in mega-linter-runner
- secretlint: remove default `.secretlintignore` that was never used but `.gitignore` is used instead. Fixes [#3328](https://github.com/oxsecurity/megalinter/issues/3328)
- Add jpeg, xlsx to .gitleaks.toml, by @rasa in https://github.com/oxsecurity/megalinter/pull/3434
- Fix Json Schema, by @nvuillam in https://github.com/oxsecurity/megalinter/pull/3470
- Remove `TEMPLATES/.secretlintignore`, by @pjungermann in https://github.com/oxsecurity/megalinter/pull/3476
- Add jpeg, xlsx to .gitleaks.toml, by @rasa in <https://github.com/oxsecurity/megalinter/pull/3434>
- Fix Json Schema, by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3470>
- Remove `TEMPLATES/.secretlintignore`, by @pjungermann in <https://github.com/oxsecurity/megalinter/pull/3476>

- Doc
- Update R2DevOps logo, by @nvuillam in https://github.com/oxsecurity/megalinter/pull/3436
- Update [Roslynator](https://github.com/dotnet/roslynator) repo url and logo, by @TommyE123 in https://github.com/oxsecurity/megalinter/pull/3444
- Fix clang-format documentation links to point to the correct version. Fixes [#3452](https://github.com/oxsecurity/megalinter/issues/3452), by @daltonv in https://github.com/oxsecurity/megalinter/pull/3453
- Add copy to clipboard button in code block (documentation), by @nikkii86 in https://github.com/oxsecurity/megalinter/pull/3491
- Update R2DevOps logo, by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3436>
- Update [Roslynator](https://github.com/dotnet/roslynator) repo url and logo, by @TommyE123 in <https://github.com/oxsecurity/megalinter/pull/3444>
- Fix clang-format documentation links to point to the correct version. Fixes [#3452](https://github.com/oxsecurity/megalinter/issues/3452), by @daltonv in <https://github.com/oxsecurity/megalinter/pull/3453>
- Add copy to clipboard button in code block (documentation), by @nikkii86 in <https://github.com/oxsecurity/megalinter/pull/3491>

- Flavors
- Add C & C++ linters in Python flavor by @nvuillam in https://github.com/oxsecurity/megalinter/pull/3456
- Add C & C++ linters in Python flavor by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3456>

- CI
- Make SPELL_LYCHEE non blocking for internal CI jobs
- Remove old unused automerge workflows by @echoix in https://github.com/oxsecurity/megalinter/pull/3432
- Add consistent python3/python handling at build.sh, by @pjungermann in https://github.com/oxsecurity/megalinter/pull/3475
- Remove old unused automerge workflows by @echoix in <https://github.com/oxsecurity/megalinter/pull/3432>
- Add consistent python3/python handling at build.sh, by @pjungermann in <https://github.com/oxsecurity/megalinter/pull/3475>

- Linter versions upgrades
- [ansible-lint](https://ansible-lint.readthedocs.io/) from 24.2.0 to **24.2.2**
Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/css_scss_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: How to use scss-lint (configure, ignore files, ignore errors, help

> This linter has been deprecated.
>
> https://github.com/sds/scss-lint#notice-consider-other-tools-before-adopting-scss-lint
> <https://github.com/sds/scss-lint#notice-consider-other-tools-before-adopting-scss-lint>
>
> You should disable scss-lint by adding it in DISABLE_LINTERS property.
>
Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/xml_xmllint.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To apply file formatting you must set `XML_XMLLINT_CLI_LINT_MODE: file` and `XML
| Variable | Description | Default value |
|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| XML_XMLLINT_AUTOFORMAT | If set to `true`, it will reformat and reindent the output | `false` |
| XML_XMLLINT_INDENT | The number of indentation spaces when `XML_XMLLINT_AUTOFORMAT` is `true` | ` ` |
| XML_XMLLINT_INDENT | The number of indentation spaces when `XML_XMLLINT_AUTOFORMAT` is `true` | `` |
| XML_XMLLINT_ARGUMENTS | User custom arguments to add in linter CLI call<br/>Ex: `-s --foo "bar"` | |
| XML_XMLLINT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter<br/>Ex: `-s --foo "bar"` | |
| XML_XMLLINT_FILTER_REGEX_INCLUDE | Custom regex including filter<br/>Ex: `(src\|lib)` | Include every file |
Expand Down
13 changes: 12 additions & 1 deletion megalinter/MegaLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,18 @@ def list_files_git_diff(self):
# Try to fetch default_branch from origin, because it isn't cached locally.
repo.git.fetch("origin", f"{remote_ref}:{local_ref}")
# Make git diff to list files (and exclude symlinks)
diff = repo.git.diff(f"{default_branch_remote}...", name_only=True)
try:
# Use optimized way from https://github.com/oxsecurity/megalinter/pull/3472
diff = repo.git.diff(f"{default_branch_remote}...", name_only=True)
except Exception as e7:
# Use previous way as fallback
logging.warning("Git diff error: " + str(e7))
logging.warning(
"You might need to add check-depth: 0 or equivalent to access merge-base"
)
logging.warning("See https://github.com/oxsecurity/megalinter/pull/3472")
logging.warning("Using fallback without merge-base...")
diff = repo.git.diff(default_branch_remote, name_only=True)
logging.info(f"Modified files:\n{diff}")
all_files = list()
for diff_line in diff.splitlines():
Expand Down
Loading