Skip to content
Open
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
6 changes: 4 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ repo-settings: ## Reconcile GitHub repository settings (labels, merge strategy,
\
echo " Configuring merge strategy..."; \
$(GH) api "repos/$$REPO" -X PATCH \
-f allow_merge_commit=true \
-f allow_squash_merge=false \
-f allow_merge_commit=false \
-f allow_squash_merge=true \
-f allow_rebase_merge=false \
-f squash_merge_commit_title=PR_TITLE \
-f squash_merge_commit_message=PR_BODY \
Comment on lines +114 to +118

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

rg -n '^\s+-f (allow_merge_commit|allow_squash_merge|allow_rebase_merge|delete_branch_on_merge|allow_auto_merge)=' common.mk

Repository: opendefensecloud/dev-kit

Length of output: 354


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== common.mk context =="
sed -n '104,122p' common.mk | cat -n

echo
echo "== search for related boolean repo patches =="
rg -n 'gh api .*PATCH .*repos|allow_merge_commit|allow_squash_merge|allow_rebase_merge|delete_branch_on_merge|allow_auto_merge' -S .

echo
echo "== gh availability/version =="
if command -v gh >/dev/null 2>&1; then
  gh version
  gh api --help | sed -n '/--raw-field\|--typed-field/p'
else
  echo "gh command not available"
fi

echo
echo "== repository settings schemas in GitHub docs? local docs? =="
rg -n 'PATCH /repos/{owner}/{repo}|allow_merge_commit|delete_branch_on_merge|type.*true|type.*false' -S . || true

Repository: opendefensecloud/dev-kit

Length of output: 1832


🌐 Web query:

GitHub CLI gh api -f vs -F raw-field typed-field boolean fields

💡 Result:

In the GitHub CLI (gh), the --field (-F) and --raw-field (-f) flags behave differently regarding how they handle data types like booleans and numbers [1][2]. --field (-F) (Typed Field): This flag supports magic type conversion based on the value provided [1]. When you use -F, the GitHub CLI attempts to interpret specific literal values as their corresponding JSON types [1]. - Booleans: Values like true and false are automatically converted to JSON boolean types [1]. - Numbers: Integer numbers are converted to JSON number types [1]. - Null: The value null is converted to a JSON null type [1]. --raw-field (-f) (Raw Field): This flag treats all values as static strings [1][2]. It does not perform any automatic type conversion or JSON parsing on the value [2]. If you need a value to be treated strictly as a string—even if it looks like a boolean or number—you should use --raw-field [2]. Summary of Key Differences: - Use --field (-F) when you want the CLI to automatically handle JSON type conversion for booleans, numbers, and null values [1]. - Use --raw-field (-f) when you want to ensure the value is sent as a string [2]. - For complex data structures such as nested objects or arrays, neither flag is typically sufficient on its own [3][4]. In such cases, the recommended practice is to prepare the full JSON payload externally and pass it to the command using --input - (reading from standard input) or a file [1][3][4]. Example Usage: # Using -F for automatic type conversion (sends JSON boolean) gh api -X PATCH /repos/{owner}/{repo} -F archived=true # Using -f for string-only (sends "true" as a string, if the API expects a string) gh api -X PATCH /repos/{owner}/{repo} -f archived="true"

Citations:


🌐 Web query:

GitHub REST API update repository PATCH body allows auto merge allow squash merge merge commit true false boolean

💡 Result:

The GitHub REST API update repository endpoint (PATCH /repos/{owner}/{repo}) supports the following boolean parameters to control merge settings, which must be passed in the request body [1]: - allow_squash_merge (boolean): Set to true to allow squash-merging pull requests, or false to prevent it. The default value is true [1]. - allow_merge_commit (boolean): Set to true to allow merging pull requests with a merge commit, or false to prevent it. The default value is true [1]. - allow_auto_merge (boolean): Set to true to allow auto-merge on pull requests, or false to disallow it. The default value is false [1]. These parameters allow you to programmatically toggle repository merge configurations by sending the desired boolean value in your JSON request body [1].

Citations:


🌐 Web query:

GitHub REST API update repository PATCH allow_rebase_merge boolean merge commit

💡 Result:

To update repository settings using the GitHub REST API, you can use the PATCH /repos/{owner}/{repo} endpoint [1][2]. The allow_rebase_merge parameter is a boolean value that controls whether rebase-merging of pull requests is enabled for the repository [1][3]. Setting this to true allows rebase-merging, while false prevents it [1][4]. The default value for this setting is true [1][3]. When updating repository merge settings, you can also configure related options using the same PATCH endpoint, such as: allow_merge_commit (boolean): Enables or disables merging pull requests with a merge commit (default: true) [3][2]. allow_squash_merge (boolean): Enables or disables squash-merging of pull requests (default: true) [2][5]. For example, a JSON request body to update these settings would look like this: { "allow_merge_commit": true, "allow_squash_merge": true, "allow_rebase_merge": false } Note that managing repository merge settings requires the contents:read and contents:write permissions [2][5]. While this PATCH endpoint manages overall repository settings, actual pull request merges are performed using the PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge endpoint, which accepts a merge_method parameter (merge, squash, or rebase) [6].

Citations:


Use typed fields for boolean repository settings.

gh api -f/--raw-field sends literal string values, but the repository PATCH fields here are defined as booleans. Use -F/--typed-field so false/true are serialized as JSON booleans; otherwise the settings update can fail validation.

Proposed fix
-		-f allow_merge_commit=false \
-		-f allow_squash_merge=true \
-		-f allow_rebase_merge=false \
+		-F allow_merge_commit=false \
+		-F allow_squash_merge=true \
+		-F allow_rebase_merge=false \
 		-f squash_merge_commit_title=PR_TITLE \
 		-f squash_merge_commit_message=PR_BODY \
-		-f delete_branch_on_merge=true \
-		-f allow_auto_merge=true > /dev/null; \
+		-F delete_branch_on_merge=true \
+		-F allow_auto_merge=true > /dev/null; \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-f allow_merge_commit=false \
-f allow_squash_merge=true \
-f allow_rebase_merge=false \
-f squash_merge_commit_title=PR_TITLE \
-f squash_merge_commit_message=PR_BODY \
-F allow_merge_commit=false \
-F allow_squash_merge=true \
-F allow_rebase_merge=false \
-f squash_merge_commit_title=PR_TITLE \
-f squash_merge_commit_message=PR_BODY \
-F delete_branch_on_merge=true \
-F allow_auto_merge=true > /dev/null; \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@common.mk` around lines 114 - 118, Update the repository settings arguments
in the make target around allow_merge_commit, allow_squash_merge, and
allow_rebase_merge to use gh’s typed-field option instead of the raw-field
option, ensuring true/false values are serialized as JSON booleans while leaving
string-valued fields unchanged.

-f delete_branch_on_merge=true \
-f allow_auto_merge=true > /dev/null; \
\
Expand Down
Loading