Skip to content

feat(github): add default rulesets and installation #47

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

fmind
Copy link
Owner

@fmind fmind commented Mar 5, 2025

Changes

Reasons

Testing

Impacts

Notes

@fmind fmind added the feat A new feature. Correlates with MINOR in SemVer label Mar 5, 2025
@fmind fmind added this to the v4.1.0 milestone Mar 5, 2025
@fmind fmind self-assigned this Mar 5, 2025
Copy link
Contributor

@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.

Hello @fmind, 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!

Summary of Changes

This pull request introduces default rulesets and installation for GitHub repositories. It adds a main.json file containing the ruleset configuration, modifies the README.md file to include a new install-rulesets task, and updates the tasks/install.just file to include the implementation for installing the GitHub rulesets using the GitHub API.

Highlights

  • Ruleset Configuration: The pull request introduces a main.json file that defines a ruleset for the main branch. This ruleset enforces several rules, including deletion restrictions, required linear history, pull request requirements (approvals, dismissal of stale reviews, merge methods), required status checks, and non-fast-forward merges.
  • Installation Task: The pull request adds a new install-rulesets task to the tasks/install.just file. This task uses the GitHub API to create a ruleset for the repository based on the configuration in main.json.
  • README Update: The README.md file is updated to include the new install-rulesets task in the list of available tasks.

Changelog

  • .github/rulesets/main.json
    • Added a new file containing the default ruleset configuration for the main branch.
    • The ruleset enforces deletion restrictions, required linear history, pull request requirements, required status checks, and non-fast-forward merges.
    • Bypass actors are configured to allow repository roles to bypass the rules.
  • README.md
    • Added install-rulesets to the list of available tasks.
  • tasks/install.just
    • Added a new install-rulesets task that uses the GitHub API to create a ruleset for the repository.
    • The task retrieves the repository name and owner using the gh CLI.
    • The task sends a POST request to the GitHub API to create the ruleset using the configuration in .github/rulesets/main.json.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Trivia time!

What is the purpose of the 'jq' command-line tool used in the install-rulesets task?

Click here for the answer
The `jq` command-line tool is a lightweight and flexible JSON processor. It is used to slice, filter, map and transform structured data.

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.

@fmind fmind merged commit 193a9b4 into v4.1.0 Mar 5, 2025
1 check passed
@fmind fmind deleted the 46-feat-automatically-set-rulesets-on-github branch March 5, 2025 19:43
Copy link
Contributor

@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 introduces default rulesets and installation for GitHub repositories using just. The changes look good overall, but there are a few areas that could be improved for clarity and maintainability.

Summary of Findings

  • Error Handling in install-rulesets: The install-rulesets task in tasks/install.just uses set -euo pipefail, which is good for general error handling. However, it might be beneficial to add specific error handling around the gh api call to provide more informative error messages or retry logic if the API call fails. I did not add a review comment for this due to the review settings.
  • Clarity of Rule Set Purpose: The main.json ruleset lacks comments explaining the purpose of each rule. Adding comments would improve readability and maintainability. I did not add a review comment for this due to the review settings.

Merge Readiness

The pull request is almost ready for merging. Addressing the suggested improvements, particularly regarding error handling and documentation, would enhance the quality and maintainability of the code. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging.

Comment on lines +23 to +24
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/$owner/$repo/rulesets" --input=".github/rulesets/main.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding a comment explaining what this command does, and what the expected output is. This will help future developers understand the purpose of this command.

    gh api --method POST -H "Accept: application/vnd.github+json" \
    "/repos/$owner/$repo/rulesets" --input=".github/rulesets/main.json" # Creates or updates the ruleset for the repository

@fmind
Copy link
Owner Author

fmind commented Mar 5, 2025

Closes by #46

@fmind fmind mentioned this pull request Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat A new feature. Correlates with MINOR in SemVer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant