Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3f127f

Browse files
authored
Merge branch 'main' into learnings
2 parentsb8c15b0 +7232fa7 commitd3f127f

File tree

7 files changed

+321
-10
lines changed

7 files changed

+321
-10
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Welcome to the official docs for [**CodeRabbit**](https://coderabbit.ai), the co
4545
2. Clone this repository:
4646

4747
```sh
48-
git clone https://github.com/coderabbit-ai/coderabbit-docs.git
48+
git clone https://github.com/coderabbitai/coderabbit-docs.git
4949
cd coderabbit-docs
5050
```
5151

‎docs/reference/configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,19 +3552,19 @@ markdownlint-cli2 is a static analysis tool to enforce standards and consistency
35523552

35533553
markdownlint-cli2 is a static analysis tool to enforce standards and consistency for Markdown files.
35543554

3555-
###OXC
3555+
###Oxlint
35563556

3557-
OXC is a JavaScript/TypeScript linter written in Rust.
3557+
Oxlint is a JavaScript/TypeScript linter for OXC written in Rust.
35583558

3559-
#### EnableOXC
3559+
#### EnableOxlint
35603560

35613561
<Tabs groupId="config-setting">
35623562
<TabItem value="web-ui" label="Web UI">
35633563
<table>
35643564
<tbody>
35653565
<tr>
35663566
<td><strong>Location</strong></td>
3567-
<td>Review > Tools > EnableOXC</td>
3567+
<td>Review > Tools > EnableOxlint</td>
35683568
</tr>
35693569
<tr>
35703570
<td><strong>Default</strong></td>
@@ -3591,7 +3591,7 @@ OXC is a JavaScript/TypeScript linter written in Rust.
35913591
</TabItem>
35923592
</Tabs>
35933593

3594-
OXC is a JavaScript/TypeScript linter written in Rust.
3594+
Oxlint is a JavaScript/TypeScript linter for OXC written in Rust.
35953595

35963596
### PHPStan
35973597

‎docs/self-hosted/gitlab.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,46 @@ Consult official CodeRabbitAI documentation for a detailed [guide](https://docs.
3737
1.**Navigate to Add Webhook Page**: Go to the webhook configuration page in the desired GitLab project.
3838
2.**Add Webhook URL**: Enter the URL pointing to the CodeRabbit service, followed by`/gitlab_webhooks` (e.g.,`http://127.0.0.1:8080/gitlab_webhooks`).
3939
3.**Generate and Save Secret Token**: Generate a secret token, add it to the webhook, and store it securely. This will be needed for the`.env` file as`GITLAB_WEBHOOK_SECRET` (you can use a single secret token for all projects).
40-
4. Select triggers:
40+
4.**Select triggers**:
4141

4242
- Push events
4343
- Comments
4444
- Issues events
4545
- Merge request events
4646

47+
##Add Webhook Using a Script
48+
49+
We have a convenient[script](/code/gitlab-webhook.sh) to help you add webhooks to a project or all projects under a group in a GitLab instance.
50+
51+
```bash
52+
# Make sure the script is executable:
53+
chmod +x gitlab-webhook.sh
54+
```
55+
56+
Example usage:
57+
58+
```bash
59+
# PAT example (header auto-detected)
60+
export GITLAB_TOKEN="glpat-xxxxx"
61+
./gitlab-add-webhook.sh \
62+
-h"gitlab.example.com" -u"http://<coderabbit-agent-addr>/gitlab_webhooks" \
63+
-s"mySecret" -p 42
64+
65+
# PAT example (explicit header)
66+
./gitlab-add-webhook.sh \
67+
-h"gitlab.example.com" -u"http://<coderabbit-agent-addr>/gitlab_webhooks" \
68+
-s"mySecret" -g"mygroup/mysubgroup/myproject" \
69+
-t"glpat-xxxxx" \
70+
-A"PRIVATE-TOKEN"
71+
72+
# OAuth token with explicit header
73+
./gitlab-add-webhook.sh \
74+
-h"gitlab.example.com" -u"http://<coderabbit-agent-addr>/gitlab_webhooks" \
75+
-s"mySecret" -g"company/backend" \
76+
-t"eyJhbGciOi..." \
77+
-A"Authorization: Bearer"
78+
```
79+
4780
##Prepare a`.env` file
4881

4982
Create a`.env` file with the following content:

‎docs/tools/dotenv.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';
1212

1313
[Dotenv Linter](https://github.com/dotenv-linter/dotenv-linter) is a lightning-fast linter for`.env` files. It helps ensure your environment files are consistent, typo-free, and follow best practices.
1414

15+
##Files
16+
17+
Dotenv Linter will run on files with the following patterns:
18+
19+
-`**/.env`
20+
-`**/.env.*`
21+
22+
We will not run against files that do not start with`.env` (e.g.,`test.env`). However`.env.dev` or`.env.local` is fine.
23+
1524
:::note
1625

1726
Dotenv Linter does not require configuration to run and automatically anlysises`.env` files. If no configuration file is found, it will use default settings.

‎sidebars.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,21 @@ const sidebars: SidebarsConfig = {
177177
"tools/list",
178178
"tools/actionlint",
179179
"tools/biome",
180+
"tools/brakeman",
180181
"tools/buf",
182+
"tools/checkmake",
181183
"tools/checkov",
182184
"tools/circleci",
185+
"tools/clippy",
183186
"tools/cppcheck",
184187
"tools/detekt",
188+
"tools/dotenv",
185189
"tools/eslint",
186190
"tools/flake8",
187191
"tools/gitleaks",
188192
"tools/golangci-lint",
189193
"tools/hadolint",
194+
"tools/htmlhint",
190195
"tools/languagetool",
191196
"tools/luacheck",
192197
"tools/markdownlint",
@@ -197,6 +202,7 @@ const sidebars: SidebarsConfig = {
197202
"tools/pipeline-remediation",
198203
"tools/pmd",
199204
"tools/prisma-lint",
205+
"tools/pylint",
200206
"tools/regal",
201207
"tools/rubocop",
202208
"tools/ruff",

‎static/code/gitlab-webhook.sh

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#!/usr/bin/env bash
2+
3+
## gitlab-webhook.sh
4+
# Add a webhook to one project, or every project in a subgroup tree.
5+
6+
## Example usage:
7+
# Make sure the script is executable:
8+
# chmod +x gitlab-webhook.sh
9+
10+
# PAT auto-detected header
11+
# export GITLAB_TOKEN="glpat-xxxxx"
12+
# ./gitlab-add-webhook.sh \
13+
# -h "gitlab.example.com" -u "https://ci.example.com/gitlab-hook" \
14+
# -s "mySecret" -p 42
15+
16+
# PAT with explicit header
17+
# ./gitlab-add-webhook.sh \
18+
# -h "gitlab.example.com" -u "https://ci.example.com/gitlab-hook" \
19+
# -s "mySecret" -g "mygroup/mysubgroup/myproject" \
20+
# -t "glpat-qj5s..." \
21+
# -A "PRIVATE-TOKEN"
22+
23+
# OAuth token with explicit header
24+
# ./gitlab-add-webhook.sh \
25+
# -h "gitlab.example.com" -u "https://ci.example.com/gitlab-hook" \
26+
# -s "mySecret" -g "company/backend" \
27+
# -t "eyJhbGciOi..." \
28+
# -A "Authorization: Bearer"
29+
30+
31+
set -euo pipefail
32+
33+
usage() {
34+
cat<<EOF
35+
Usage:
36+
$0 -h <gitlab-host> -u <webhook-url> -s <webhook-secret>\\
37+
[-t <access-token>] [-A <auth-header>] [-p <project> | -g <group>]
38+
39+
Required:
40+
-h GitLab host (e.g. gitlab.example.com)
41+
-u Webhook endpoint URL to receive POSTs
42+
-s Webhook secret token (used for signature verification)
43+
44+
Authentication (one of):
45+
-t Access token (PAT, project, group or OAuth). If omitted,\$GITLAB_TOKEN is used
46+
-A Auth header to use. Default detects:
47+
PAT → "PRIVATE-TOKEN"
48+
anything else → "Authorization: Bearer"
49+
50+
Scope (choose one):
51+
-p Project ID or full path (e.g. 42 or group/app)
52+
-g Group ID or full path, recurse through all subgroups & projects
53+
EOF
54+
exit 1
55+
}
56+
57+
HOST="" HOOK_URL="" HOOK_SECRET=""
58+
TOKEN="${GITLAB_TOKEN:-}" AUTH_HEADER=""
59+
PROJECT="" GROUP=""
60+
61+
whilegetopts"h:u:s:t:A:p:g:" opt;do
62+
case"$opt"in
63+
h) HOST=$OPTARG ;;
64+
u) HOOK_URL=$OPTARG ;;
65+
s) HOOK_SECRET=$OPTARG ;;
66+
t) TOKEN=$OPTARG ;;
67+
A) AUTH_HEADER=$OPTARG ;;
68+
p) PROJECT=$OPTARG ;;
69+
g) GROUP=$OPTARG ;;
70+
*) usage ;;
71+
esac
72+
done
73+
74+
# Mandatory checks
75+
[[-z$HOST||-z$HOOK_URL||-z$HOOK_SECRET ]]&& usage
76+
[[-n$PROJECT&&-n$GROUP ]]&& usage
77+
[[-z$PROJECT&&-z$GROUP ]]&& usage
78+
79+
# Token handling
80+
if [[-z$TOKEN ]];then
81+
echo"❌ No access token provided. Use -t or set\$GITLAB_TOKEN">&2
82+
exit 1
83+
fi
84+
85+
# Choose header if not forced
86+
if [[-z$AUTH_HEADER ]];then
87+
if [[$TOKEN== glpat-*||$TOKEN=="PAT-"* ]];then
88+
AUTH_HEADER="PRIVATE-TOKEN"
89+
else
90+
AUTH_HEADER="Authorization: Bearer"
91+
fi
92+
fi
93+
94+
API="https://${HOST}/api/v4"
95+
CURL_BASE=(curl -sSf --header"${AUTH_HEADER}:${TOKEN}")
96+
97+
# Track processed projects to avoid duplicates
98+
declare -A PROCESSED_PROJECTS
99+
# Track projects where webhooks were successfully added
100+
WEBHOOK_PROJECTS=()
101+
102+
##############################################################################
103+
# Helpers
104+
##############################################################################
105+
url_encode() {
106+
local string="$1"
107+
# URL encode the string using printf and sed
108+
printf'%s'"$string"| sed's/\//%2F/g; s/ /%20/g; s/@/%40/g; s/:/%3A/g; s/#/%23/g; s/?/%3F/g; s/&/%26/g; s/=/%3D/g; s/+/%2B/g'
109+
}
110+
111+
create_hook() {
112+
local pid=$1
113+
114+
# Skip if already processed
115+
if [[-n"${PROCESSED_PROJECTS[$pid]:-}" ]];then
116+
return 0
117+
fi
118+
119+
# Mark as processed
120+
PROCESSED_PROJECTS[$pid]=1
121+
122+
local encoded_pid
123+
# URL encode if pid is not purely numeric
124+
if [[$pid=~ ^[0-9]+$ ]];then
125+
encoded_pid=$pid
126+
else
127+
encoded_pid=$(url_encode"$pid")
128+
fi
129+
130+
"${CURL_BASE[@]}" --request POST \
131+
--data-urlencode"url=${HOOK_URL}" \
132+
--data"token=${HOOK_SECRET}" \
133+
--data"push_events=true" \
134+
--data"note_events=true" \
135+
--data"issues_events=true" \
136+
--data"merge_requests_events=true" \
137+
--data"enable_ssl_verification=true" \
138+
"${API}/projects/${encoded_pid}/hooks" \
139+
>/dev/null
140+
141+
# Track successful webhook creation
142+
WEBHOOK_PROJECTS+=("$pid")
143+
}
144+
145+
traverse_group() {
146+
local gid=$1
147+
local encoded_gid
148+
# URL encode if gid is not purely numeric
149+
if [[$gid=~ ^[0-9]+$ ]];then
150+
encoded_gid=$gid
151+
else
152+
encoded_gid=$(url_encode"$gid")
153+
fi
154+
# projects (includes nested sub-groups)
155+
while IFS=read -r pid;do
156+
[[-n"$pid" ]]&& create_hook"$pid"
157+
done<<(
158+
"${CURL_BASE[@]}" \
159+
"${API}/groups/${encoded_gid}/projects?include_subgroups=true&per_page=100"|
160+
jq -r'.[].id'
161+
)
162+
# recurse explicit subgroups (older GitLab)
163+
while IFS=read -r sg;do
164+
[[-n"$sg" ]]&& traverse_group"$sg"
165+
done<<(
166+
"${CURL_BASE[@]}""${API}/groups/${encoded_gid}/subgroups?per_page=100"|
167+
jq -r'.[].id'
168+
)
169+
}
170+
171+
##############################################################################
172+
# Main
173+
##############################################################################
174+
if [[-n$PROJECT ]];then
175+
create_hook"$PROJECT"
176+
else
177+
traverse_group"$GROUP"
178+
fi
179+
180+
# Print final summary
181+
if [[${#WEBHOOK_PROJECTS[@]}-eq 0 ]];then
182+
echo"❌ No webhooks were installed."
183+
else
184+
echo"✅ Webhooks installed successfully on${#WEBHOOK_PROJECTS[@]} project(s):"
185+
forpidin"${WEBHOOK_PROJECTS[@]}";do
186+
echo" - Project ID:$pid"
187+
done
188+
fi

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp