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

Don't require the full Git history #5626

Open
1 task done
brennovich opened this issue May 6, 2024 · 4 comments
Open
1 task done

Don't require the full Git history #5626

brennovich opened this issue May 6, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@brennovich
Copy link

brennovich commented May 6, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Version 6 requires fetch-depth: 0, however this is not feasible for every repo, for repos with long history a clone can take too much time.

Expected Behavior

Be able to disable whatever lints that requires complete git history

Super-Linter version

v6.Y.Z

Relevant log output

2024-05-06 14:23:15 [INFO]   Validating the configuration
  .git
  2024-05-06 14:23:16 [INFO]   Check that the local repository has the full history and that the repository is not shallow.
  2024-05-06 14:23:16 [INFO]   Check that you set the 'fetch-depth: 0' option for the actions/checkout step in your GitHub Actions workflow.
  2024-05-06 14:23:16 [INFO]   See https://github.com/super-linter/super-linter#get-started
  2024-05-06 14:23:16 [INFO]   Is shallow repository: true

Steps To Reproduce

-  uses: actions/checkout@v4

Anything else?

No response

@brennovich brennovich added the bug Something isn't working label May 6, 2024
@ferrarimarco
Copy link
Collaborator

ferrarimarco commented May 6, 2024

Hi! This looks like an enhancement request, also considering that this particular implementation didn't change.

What changed is that we fixed a couple of bugs that prevented this error for being reported, and we improved the error message.

We don't probably need the whole history, but we would be fine with the number of commits that allow super-linter to correctly get changes in case VALIDATE_ALL_CODEBASE is false (the default).

You can try setting fetch depth to a number > 0 and see if that works.

In that case, we might update the documentation and the error message to reflect that.

@ferrarimarco ferrarimarco added enhancement New feature or request and removed bug Something isn't working labels May 6, 2024
@ferrarimarco ferrarimarco changed the title Upgrade to version 6 breaks pipelines Don't require the full Git history May 6, 2024
@ferrarimarco
Copy link
Collaborator

In other words, we need a number of commits that allows these two commands to run:

DIFF_GIT_DEFAULT_BRANCH_CMD="git -C \"${GITHUB_WORKSPACE}\" diff --diff-filter=d --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"

DIFF_TREE_CMD="git -C \"${GITHUB_WORKSPACE}\" diff-tree --no-commit-id --name-only -r --root ${GITHUB_SHA} ${GITHUB_BEFORE_SHA} | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"

so super-linter can correctly get diffs.

This is something that super-linter cannot know in advance because the actions/checkout happens before super-linter even runs.

What super-linter might do is to require a fetch depth >0 (i.e. require that a repository is not shallow), and check if the number of commits is enough to compute the diff. Although this is not clear yet.

@brennovich
Copy link
Author

How did it work in the version 5? Oh! I just checked: https://github.com/super-linter/super-linter/blob/v5.7.2/lib/functions/buildFileList.sh#L99

@ferrarimarco
Copy link
Collaborator

That way could potentially alter the state of the local repository, which is something that we don't want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants