Skip to content

fix: makefile not working#2440

Merged
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:fix-makefile
Feb 2, 2026
Merged

fix: makefile not working#2440
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:fix-makefile

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Feb 2, 2026

with latest we are getting this error:

% make lint-go
Makefile:92: *** multiple target patterns.  Stop.

cleanup the targets to don't depend ont the files and updated the Makefile to use git ls-files with null-delimited output for generating file lists for linters instead of getting any files that are as well may be ignroed.

📝 Description of the Change

👨🏻‍ Linked Jira

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Updated the Makefile to use `git ls-files` with null-delimited output
for generating file lists for linters. This change ensures that the
linters operate on files tracked by Git, preventing unintended linting
of untracked or ignored files. Additionally, it refactored the way file
patterns are defined and utilized, improving the robustness and
maintainability of the linting targets.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Copilot AI review requested due to automatic review settings February 2, 2026 12:58
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue preventing Makefile linting targets from executing due to a "multiple target patterns" error. The core solution involves refactoring how file lists are generated for various linting and fixing tasks, moving from a find-based approach to a more robust git ls-files method. This change not only resolves the immediate error but also significantly improves the accuracy and efficiency of file discovery by leveraging Git's knowledge of tracked files and respecting exclusion patterns, leading to a more reliable and maintainable build process.

Highlights

  • Makefile Fix: Resolved a "multiple target patterns" error in the Makefile that was preventing linting tasks from running, ensuring the build process can proceed without interruption.
  • Improved File Discovery: Switched from find commands to git ls-files -z | xargs -0 for generating file lists for linting and fixing targets. This approach ensures that only tracked files are processed and respects .gitignore rules, leading to more accurate and efficient operations.
  • Refined File Patterns: Introduced specific pattern variables (e.g., PY_PATTERNS, YAML_PATTERNS) to accurately include and exclude files (such as those in vendor/ or tmp/ directories) from linting and fixing operations, preventing unnecessary processing of ignored or temporary files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code
Copy link
Copy Markdown

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🎫 Jira reference

Add a Jira reference in the description using one of the following formats:

  • https://issues.redhat.com/browse/SRVKP-<number>

If no SRVKP ticket exists yet, link a GitHub issue instead (e.g., Fixes #123).
Minor housekeeping PRs without Jira coverage can skip this after confirming with reviewers.


🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 02c479a fix: Update Makefile to use git ls-files for lint

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@pipelines-as-code pipelines-as-code bot added cleanup fix go Pull requests that update Go code labels Feb 2, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves the multiple target patterns error in the Makefile by removing file dependencies from phony targets. The switch to git ls-files from find for file discovery is a great improvement for performance and correctness, especially with the proper handling of special filenames using -z and xargs -0. I have one suggestion to improve the consistency of error handling in one of the fixing targets.

fix-trailing-spaces: ## remove trailing spaces on all markdown and yaml file
@sed --in-place 's/[[:space:]]\+$$//' $(MD_FILES) $(YAML_FILES)
@[[ -n `git status --porcelain $(MD_FILES) $(YAML_FILES)` ]] && { echo "Markdowns and Yaml files has been cleaned 🧹. Cleaned Files: ";git status --porcelain $(MD_FILES) $(YAML_FILES) ;} || echo "Markdown and YAML are clean ✨"
@$(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) sed --in-place 's/[[:space:]]\+$$//'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other fixing targets like fix-markdownlint and fix-python-errors, consider adding || true to the sed command. This will make the fix-linters target more robust by preventing it from failing if sed encounters an error (e.g., due to file permissions).

    @$(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) sed --in-place 's/[[:space:]]\+$$//' || true

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request aims to fix a "multiple target patterns" error in the Makefile by refactoring the file discovery mechanism. Instead of using variables that store file lists as target dependencies (which caused the error), the PR introduces a GIT_LS_FILES macro that uses git ls-files with null-delimited output to generate file lists dynamically.

Changes:

  • Removed file list variables (PY_FILES, SH_FILES, YAML_FILES, MD_FILES) that were causing target pattern errors
  • Added GIT_LS_FILES macro and pattern-based file selection using git pathspecs
  • Updated all lint and fix targets to use the new pattern-based approach instead of file dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

lint-shell: ## runs shellcheck on all shell files
@echo "Linting shell script files..."
@shellcheck $(SH_FILES)
@$(call GIT_LS_FILES,$(SH_PATTERNS)) shellcheck || true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint-shell target has the same critical issue. The shellcheck command won't receive the file list from xargs properly.

Suggested change
@$(call GIT_LS_FILES,$(SH_PATTERNS)) shellcheck || true
@git ls-files -z -- $(SH_PATTERNS) | xargs -0 shellcheck || true

Copilot uses AI. Check for mistakes.
fix-markdownlint: ## run markdownlint and fix on all markdown file
@echo "Fixing markdown files..."
@markdownlint --fix $(MD_FILES)
@$(call GIT_LS_FILES,$(MD_PATTERNS)) markdownlint --fix || true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix-markdownlint target has the same critical issue with command execution as the lint targets.

Suggested change
@$(call GIT_LS_FILES,$(MD_PATTERNS)) markdownlint --fix || true
@git ls-files -z -- $(MD_PATTERNS) | xargs -0 -r markdownlint --fix || true

Copilot uses AI. Check for mistakes.
@STATUS=$$($(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) git status --porcelain) && \
[[ -n "$$STATUS" ]] && { echo "Markdowns and Yaml files has been cleaned 🧹. Cleaned Files: "; echo "$$STATUS" ;} || echo "Markdown and YAML are clean ✨"

.PHONE: fix-python-errors
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in target declaration: ".PHONE:" should be ".PHONY:". This will prevent Make from recognizing this as a phony target.

Suggested change
.PHONE: fix-python-errors
.PHONY: fix-python-errors

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +150
@$(call GIT_LS_FILES,$(PY_PATTERNS)) ruff check --fix || true
@$(call GIT_LS_FILES,$(PY_PATTERNS)) ruff format || true
@STATUS=$$($(call GIT_LS_FILES,$(PY_PATTERNS)) git status --porcelain) && \
[[ -n "$$STATUS" ]] && { echo "Python files has been cleaned 🧹. Cleaned Files: "; echo "$$STATUS" ;} || echo "Python files are clean ✨"
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix-python-errors target has the same critical command execution issue with ruff commands. Additionally, line 149 has the same problem as the fix-trailing-spaces target where it tries to pipe file lists to git status --porcelain, which doesn't accept filenames from stdin.

Copilot uses AI. Check for mistakes.
MD_FILES := $(shell find . -type f -name "*.md" -not -path "./tmp/*" -not -path "./vendor/*" -not -path "*/.venv/*" -not -path "./.vale/*" -not -path "./docs/themes/*" -not -path "./.git/*" -not -path "./worktrees/*" -print)

# Safe file list helpers using null-delimited output
GIT_LS_FILES = git ls-files -z $(1) | xargs -0
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GIT_LS_FILES macro has a critical syntax issue. The xargs command outputs filenames but doesn't pipe them to the next command. When called like $(call GIT_LS_FILES,patterns) command, the files from xargs won't be passed to the command. The macro should likely be defined as just git ls-files -z $(1) so the calling sites can pipe it properly, or it needs to use xargs to invoke the command properly. Currently, the expanded command would be something like git ls-files -z patterns | xargs -0 yamllint which won't work because xargs needs the command to execute.

Copilot uses AI. Check for mistakes.
lint-yaml: ## runs yamllint on all yaml files
@echo "Linting yaml files..."
@yamllint -c .yamllint $(YAML_FILES)
@$(call GIT_LS_FILES,$(YAML_PATTERNS)) yamllint -c .yamllint || true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint-yaml target uses the GIT_LS_FILES macro incorrectly. With the current macro definition, this expands to git ls-files -z patterns | xargs -0 yamllint -c .yamllint which treats "yamllint" as a file argument to xargs rather than a command to execute. The correct approach would be either: (1) Change the macro to just output files: git ls-files -z patterns | xargs -0 -n 100 yamllint -c .yamllint, or (2) Define the macro differently to accept the command as a parameter.

Copilot uses AI. Check for mistakes.
lint-md: ## runs markdownlint and vale on all markdown files
@echo "Linting markdown files..."
@markdownlint $(MD_FILES)
@$(call GIT_LS_FILES,$(MD_PATTERNS)) markdownlint || true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint-md target has the same issue as lint-yaml. The expansion git ls-files -z patterns | xargs -0 markdownlint doesn't correctly pass the command to xargs. This will fail to execute markdownlint on the discovered files.

Suggested change
@$(call GIT_LS_FILES,$(MD_PATTERNS)) markdownlint || true
@$(call GIT_LS_FILES,$(MD_PATTERNS),markdownlint) || true

Copilot uses AI. Check for mistakes.
Comment on lines +113 to +114
@$(call GIT_LS_FILES,$(PY_PATTERNS)) ruff check || true
@$(call GIT_LS_FILES,$(PY_PATTERNS)) ruff format --check || true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint-python target has the same critical issue with command execution. Both ruff check and ruff format commands won't receive the file list properly from xargs.

Copilot uses AI. Check for mistakes.
fix-trailing-spaces: ## remove trailing spaces on all markdown and yaml file
@sed --in-place 's/[[:space:]]\+$$//' $(MD_FILES) $(YAML_FILES)
@[[ -n `git status --porcelain $(MD_FILES) $(YAML_FILES)` ]] && { echo "Markdowns and Yaml files has been cleaned 🧹. Cleaned Files: ";git status --porcelain $(MD_FILES) $(YAML_FILES) ;} || echo "Markdown and YAML are clean ✨"
@$(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) sed --in-place 's/[[:space:]]\+$$//'
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix-trailing-spaces target runs sed on file paths returned from git ls-files without placing a -- separator before the file list, so any Markdown/YAML file whose name begins with - can be interpreted by sed as an option (for example -f), causing it to load and execute a sed script from another repo-controlled file. An attacker who can introduce such filenames via a pull request could trigger arbitrary sed commands (including the e command that executes shell) when a maintainer or CI runs this target, leading to code execution in that environment. To harden this, ensure sed (and other tools) are invoked with a clear end-of-options marker so filenames cannot be treated as flags, or otherwise restrict/normalize filenames before passing them as arguments.

Suggested change
@$(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) sed --in-place 's/[[:space:]]\+$$//'
@$(call GIT_LS_FILES,$(MD_YAML_PATTERNS)) sed --in-place 's/[[:space:]]\+$$//' --

Copilot uses AI. Check for mistakes.
@chmouel chmouel merged commit 8acc23b into tektoncd:main Feb 2, 2026
8 checks passed
chmouel added a commit to chmouel/pipelines-as-code that referenced this pull request Feb 2, 2026
Address code review feedback from PR tektoncd#2440:
- Fix macro to pass command as second argument to xargs
- Fix .PHONE typo to .PHONY for fix-python-errors target
- Fix git status --porcelain usage (doesn't read from stdin)
- Add || true to sed for consistency with other fix targets
- Add -- separator to sed to prevent filename injection

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Assisted-by: Claude Opus 4.5 (via Claude Code)
chmouel added a commit to chmouel/pipelines-as-code that referenced this pull request Feb 2, 2026
Address code review feedback from PR tektoncd#2440:
- Fix macro to pass command as second argument to xargs
- Fix .PHONE typo to .PHONY for fix-python-errors target
- Fix git status --porcelain usage (doesn't read from stdin)
- Add || true to sed for consistency with other fix targets
- Add -- separator to sed to prevent filename injection

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Assisted-by: Claude Opus 4.5 (via Claude Code)
@chmouel chmouel mentioned this pull request Feb 2, 2026
41 tasks
chmouel added a commit that referenced this pull request Feb 2, 2026
Address code review feedback from PR #2440:
- Fix macro to pass command as second argument to xargs
- Fix .PHONE typo to .PHONY for fix-python-errors target
- Fix git status --porcelain usage (doesn't read from stdin)
- Add || true to sed for consistency with other fix targets
- Add -- separator to sed to prevent filename injection

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Assisted-by: Claude Opus 4.5 (via Claude Code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup fix go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants