Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit 7c8a192

Browse files
committed
Update issue-fix-mode.sh to check comment author instead of issue creator for org membership
1 parent d3c93da commit 7c8a192

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/issue-fix-mode.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ FEEDBACK=$9
1515
REQUIRE_ORG_MEMBERSHIP=${10:-"true"}
1616
ORGANIZATION=${11:-$REPO_OWNER}
1717
PERSONAL_ACCESS_TOKEN=${12:-$GITHUB_TOKEN}
18+
COMMENT_AUTHOR=${13:-""}
1819

1920
# Enable debug mode if requested
2021
if [[ "$DEBUG_MODE" == "true" ]]; then
@@ -139,31 +140,40 @@ ISSUE_AUTHOR=$(echo "$ISSUE_DETAILS" | jq -r '.author.login')
139140

140141
# Check if user is a member of the organization if required
141142
if [[ "$REQUIRE_ORG_MEMBERSHIP" == "true" ]]; then
142-
echo "Checking if $ISSUE_AUTHOR is a member of organization $ORGANIZATION"
143+
# Use the comment author for the org membership check if provided, otherwise fall back to issue author
144+
CHECK_USER="${COMMENT_AUTHOR:-$ISSUE_AUTHOR}"
145+
echo "Checking if $CHECK_USER is a member of organization $ORGANIZATION"
146+
147+
# Debug output
148+
echo "Comment Author: $COMMENT_AUTHOR"
149+
echo "Issue Author: $ISSUE_AUTHOR"
150+
echo "User being checked: $CHECK_USER"
143151

144152
# Temporarily use the personal access token for org membership check if provided
145153
if [[ "$PERSONAL_ACCESS_TOKEN" != "$GITHUB_TOKEN" ]]; then
154+
echo "Using Personal Access Token for organization membership check"
146155
# Save current token auth
147156
TEMP_AUTH=$(gh auth status 2>&1 | grep "Logged in")
148157
# Switch to personal token for org check
149158
echo "$PERSONAL_ACCESS_TOKEN" | gh auth login --with-token
150-
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$ISSUE_AUTHOR --silent -i || true)
159+
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$CHECK_USER --silent -i || true)
151160
# Switch back to github token
152161
echo "$GITHUB_TOKEN" | gh auth login --with-token
153162
else
154-
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$ISSUE_AUTHOR --silent -i || true)
163+
echo "Using GitHub Token for organization membership check"
164+
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$CHECK_USER --silent -i || true)
155165
fi
156166

157167
STATUS_CODE=$(echo "$ORG_CHECK" | head -n 1 | cut -d' ' -f2)
158168

159169
if [[ "$STATUS_CODE" != "204" ]]; then
160-
echo "User $ISSUE_AUTHOR is not a member of organization $ORGANIZATION. Skipping Claude fix."
170+
echo "User $CHECK_USER is not a member of organization $ORGANIZATION. Skipping Claude fix."
161171

162172
# Leave a comment on the issue explaining why the fix is skipped
163-
ISSUE_COMMENT=$(cat <<EOF
173+
ISSUE_COMMENT=$(cat <<'EOF'
164174
# Claude Code Fix Skipped
165175
166-
Sorry, Claude Code can only fix issues created by organization members.
176+
Sorry, Claude Code can only fix issues when the command comes from an organization member.
167177
168178
This is to prevent API usage from users outside the organization.
169179
@@ -178,7 +188,7 @@ EOF
178188
echo "Exiting due to non-organization member request"
179189
exit 0
180190
else
181-
echo "User $ISSUE_AUTHOR is a member of organization $ORGANIZATION. Proceeding with Claude fix."
191+
echo "User $CHECK_USER is a member of organization $ORGANIZATION. Proceeding with Claude fix."
182192
fi
183193
fi
184194

0 commit comments

Comments
 (0)