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

feat: Add support for executing pre-receive hooks #908

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

fabiovincenzi
Copy link

This PR adds support for managing pre-receive hooks by executing .sh scripts located in the ./hooks directory. These scripts allow administrators to define conditions for automatically approving or rejecting pushes.

Changes Introduced

  • Implement execution of .sh scripts in the ./hooks directory to validate pushes.
  • Add basic tests to verify hook execution functionality.

You can also test this feature using the following pre-receive samples. Simply place a sample script in the ./hooks directory and attempt a push. The script should execute and determine whether the push is accepted or rejected.

Copy link

linux-foundation-easycla bot commented Feb 17, 2025

CLA Not Signed

Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 54970fb
🔍 Latest deploy log https://app.netlify.com/sites/endearing-brigadeiros-63f9d0/deploys/67bee1bb8dc3010008f52f5c

@fabiovincenzi fabiovincenzi changed the title Add support for executing pre-receive hooks feat: Add support for executing pre-receive hooks Feb 17, 2025
@JamieSlome
Copy link
Member

@06kellyjac (cc) 🍰

@JamieSlome JamieSlome self-requested a review February 21, 2025 10:06
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.01%. Comparing base (1cde9ac) to head (54970fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
+ Coverage   63.20%   64.01%   +0.81%     
==========================================
  Files          47       48       +1     
  Lines        1685     1723      +38     
==========================================
+ Hits         1065     1103      +38     
  Misses        620      620              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@JamieSlome JamieSlome left a comment

Choose a reason for hiding this comment

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

Another solid G-PR 😏

Can you confirm my understanding? This PR supports the definition and execution of .sh scripts which can be exposed to the chain via the hooks folder?

@JamieSlome
Copy link
Member

Just a reminder to get the EasyCLA signed and we're good to proceed 🍰

@fabiovincenzi
Copy link
Author

Another solid G-PR 😏

Can you confirm my understanding? This PR supports the definition and execution of .sh scripts which can be exposed to the chain via the hooks folder?

Thank you @JamieSlome for the review!
Exactly that is the flow🙌🏻

@JamieSlome
Copy link
Member

JamieSlome commented Feb 24, 2025

Thanks for the clarifications and updates ❤️ Once the EasyCLA is signed I'll merge the PR 🍰

EDIT: and release 🚀

@fabiovincenzi
Copy link
Author

fabiovincenzi commented Feb 26, 2025

@JamieSlome I added a check to verify whether the pre-receive hook exists. If it doesn’t, we simply skip its execution without any errors. This way, the check is only enforced if both the hooks folder and the pre-receive file are present. What do you think?

Aside from that, we were considering implementing auto-approval of pushes using this hook. I'll create a separate PR for that, but perhaps adding a configuration option like enable-auto-approval: true could allow pushes to be automatically approved and pushed to the upstream, or maybe define something like:

  • status = 0 -> auto-approve.
  • status = 1 -> auto-reject.
  • status = 2 -> manual-approving.

We are working to get the EasyCLA signed, thanks again!😊

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

Successfully merging this pull request may close these issues.

2 participants