-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix conflict #43
Open
gitworkflows
wants to merge
1
commit into
old/main
Choose a base branch
from
fix/confl
base: old/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix conflict #43
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -80,7 +80,7 @@ async def handle_comments_on_pr(body: Dict[str, Any], | |||||||||
event: str, | ||||||||||
sender: str, | ||||||||||
sender_id: str, | ||||||||||
action: str, | ||||||||||
action_type: str, | ||||||||||
log_context: Dict[str, Any], | ||||||||||
action: PRAction): | ||||||||||
if "comment" not in body: | ||||||||||
|
@@ -124,18 +124,18 @@ async def handle_new_pr_opened(body: Dict[str, Any], | |||||||||
event: str, | ||||||||||
sender: str, | ||||||||||
sender_id: str, | ||||||||||
action: str, | ||||||||||
action_type: str, | ||||||||||
log_context: Dict[str, Any], | ||||||||||
action: PRAction): | ||||||||||
title = body.get("pull_request", {}).get("title", "") | ||||||||||
get_settings().config.is_auto_command = True | ||||||||||
|
||||||||||
|
||||||||||
pull_request, api_url = _check_pull_request_event(action, body, log_context) | ||||||||||
pull_request, api_url = _check_pull_request_event(action_type, body, log_context) | ||||||||||
if not (pull_request and api_url): | ||||||||||
get_logger().info(f"Invalid PR event: {action=} {api_url=}") | ||||||||||
get_logger().info(f"Invalid PR event: {action_type=} {api_url=}") | ||||||||||
return {} | ||||||||||
if action in get_settings().github_app.handle_pr_actions: # ['opened', 'reopened', 'ready_for_review'] | ||||||||||
if action_type in get_settings().github_app.handle_pr_actions: # ['opened', 'reopened', 'ready_for_review'] | ||||||||||
# logic to ignore PRs with specific titles (e.g. "[Auto] ...") | ||||||||||
apply_repo_settings(api_url) | ||||||||||
ignore_pr_title_re = get_settings().get("GITHUB_APP.IGNORE_PR_TITLE", []) | ||||||||||
|
@@ -154,10 +154,10 @@ async def handle_push_trigger_for_new_commits(body: Dict[str, Any], | |||||||||
event: str, | ||||||||||
sender: str, | ||||||||||
sender_id: str, | ||||||||||
action: str, | ||||||||||
action_type: str, | ||||||||||
log_context: Dict[str, Any], | ||||||||||
action: PRAction): | ||||||||||
pull_request, api_url = _check_pull_request_event(action, body, log_context) | ||||||||||
pull_request, api_url = _check_pull_request_event(action_type, body, log_context) | ||||||||||
if not (pull_request and api_url): | ||||||||||
return {} | ||||||||||
|
||||||||||
|
@@ -204,7 +204,7 @@ async def handle_push_trigger_for_new_commits(body: Dict[str, Any], | |||||||||
|
||||||||||
try: | ||||||||||
if get_identity_provider().verify_eligibility("github", sender_id, api_url) is not Eligibility.NOT_ELIGIBLE: | ||||||||||
get_logger().info(f"Performing incremental review for {api_url=} because of {event=} and {action=}") | ||||||||||
get_logger().info(f"Performing incremental review for {api_url=} because of {event=} and {action_type=}") | ||||||||||
await _perform_auto_commands_github("push_commands", action, body, api_url, log_context) | ||||||||||
|
||||||||||
finally: | ||||||||||
|
@@ -214,7 +214,7 @@ async def handle_push_trigger_for_new_commits(body: Dict[str, Any], | |||||||||
_duplicate_push_triggers[api_url] -= 1 | ||||||||||
|
||||||||||
|
||||||||||
def handle_closed_pr(body, event, action, log_context): | ||||||||||
def handle_closed_pr(body, event, action_type, log_context): | ||||||||||
pull_request = body.get("pull_request", {}) | ||||||||||
is_merged = pull_request.get("merged", False) | ||||||||||
if not is_merged: | ||||||||||
|
@@ -225,7 +225,7 @@ def handle_closed_pr(body, event, action, log_context): | |||||||||
get_logger().info("PR-Action statistics for closed PR", analytics=True, pr_statistics=pr_statistics, **log_context) | ||||||||||
|
||||||||||
|
||||||||||
def get_log_context(body, event, action, build_number): | ||||||||||
def get_log_context(body, event, action_type, build_number): | ||||||||||
sender = "" | ||||||||||
sender_id = "" | ||||||||||
sender_type = "" | ||||||||||
|
@@ -237,7 +237,7 @@ def get_log_context(body, event, action, build_number): | |||||||||
git_org = body.get("organization", {}).get("login", "") | ||||||||||
installation_id = body.get("installation", {}).get("id", "") | ||||||||||
app_name = get_settings().get("CONFIG.APP_NAME", "Unknown") | ||||||||||
log_context = {"action": action, "event": event, "sender": sender, "server_type": "github_app", | ||||||||||
log_context = {"action_type": action_type, "event": event, "sender": sender, "server_type": "github_app", | ||||||||||
"request_id": uuid.uuid4().hex, "build_number": build_number, "app_name": app_name, | ||||||||||
"repo": repo, "git_org": git_org, "installation_id": installation_id} | ||||||||||
except Exception as e: | ||||||||||
|
@@ -254,11 +254,11 @@ async def handle_request(body: Dict[str, Any], event: str): | |||||||||
body: The request body. | ||||||||||
event: The GitHub event type (e.g. "pull_request", "issue_comment", etc.). | ||||||||||
""" | ||||||||||
action = body.get("action") # "created", "opened", "reopened", "ready_for_review", "review_requested", "synchronize" | ||||||||||
if not action: | ||||||||||
action_type = body.get("action_type") # "created", "opened", "reopened", "ready_for_review", "review_requested", "synchronize" | ||||||||||
if not action_type: | ||||||||||
return {} | ||||||||||
action = PRAction() | ||||||||||
log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number) | ||||||||||
log_context, sender, sender_id, sender_type = get_log_context(body, event, action_type, build_number) | ||||||||||
|
||||||||||
# logic to ignore PRs opened by bot | ||||||||||
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot": | ||||||||||
|
@@ -270,24 +270,24 @@ async def handle_request(body: Dict[str, Any], event: str): | |||||||||
# get_logger().debug(f'Request body', artifact=body, event=event) # added inside handle_checks | ||||||||||
pass | ||||||||||
# handle comments on PRs | ||||||||||
elif action == 'created': | ||||||||||
elif action_type == 'created': | ||||||||||
get_logger().debug(f'Request body', artifact=body, event=event) | ||||||||||
await handle_comments_on_pr(body, event, sender, sender_id, action, log_context, action) | ||||||||||
await handle_comments_on_pr(body, event, sender, sender_id, action_type, log_context, action) | ||||||||||
# handle new PRs | ||||||||||
elif event == 'pull_request' and action != 'synchronize' and action != 'closed': | ||||||||||
elif event == 'pull_request' and action_type != 'synchronize' and action_type != 'closed': | ||||||||||
get_logger().debug(f'Request body', artifact=body, event=event) | ||||||||||
await handle_new_pr_opened(body, event, sender, sender_id, action, log_context, action) | ||||||||||
elif event == "issue_comment" and 'edited' in action: | ||||||||||
await handle_new_pr_opened(body, event, sender, sender_id, action_type, log_context, action) | ||||||||||
elif event == "issue_comment" and 'edited' in action_type: | ||||||||||
pass # handle_checkbox_clicked | ||||||||||
# handle pull_request event with synchronize action - "push trigger" for new commits | ||||||||||
elif event == 'pull_request' and action == 'synchronize': | ||||||||||
# handle pull_request event with synchronize action_type - "push trigger" for new commits | ||||||||||
elif event == 'pull_request' and action_type == 'synchronize': | ||||||||||
# get_logger().debug(f'Request body', artifact=body, event=event) # added inside handle_push_trigger_for_new_commits | ||||||||||
await handle_push_trigger_for_new_commits(body, event, sender,sender_id, action, log_context, action) | ||||||||||
elif event == 'pull_request' and action == 'closed': | ||||||||||
await handle_push_trigger_for_new_commits(body, event, sender,sender_id, action_type, log_context, action) | ||||||||||
elif event == 'pull_request' and action_type == 'closed': | ||||||||||
if get_settings().get("CONFIG.ANALYTICS_FOLDER", ""): | ||||||||||
handle_closed_pr(body, event, action, log_context) | ||||||||||
handle_closed_pr(body, event, action_type, log_context) | ||||||||||
else: | ||||||||||
get_logger().info(f"event {event=} action {action=} does not require any handling") | ||||||||||
get_logger().info(f"event {event=} action_type {action_type=} does not require any handling") | ||||||||||
return {} | ||||||||||
|
||||||||||
|
||||||||||
|
@@ -308,7 +308,7 @@ def handle_line_comments(body: Dict, comment_body: [str, Any]) -> str: | |||||||||
return comment_body | ||||||||||
|
||||||||||
|
||||||||||
def _check_pull_request_event(action: str, body: dict, log_context: dict) -> Tuple[Dict[str, Any], str]: | ||||||||||
def _check_pull_request_event(action_type: str, body: dict, log_context: dict) -> Tuple[Dict[str, Any], str]: | ||||||||||
invalid_result = {}, "" | ||||||||||
pull_request = body.get("pull_request") | ||||||||||
if not pull_request: | ||||||||||
|
@@ -319,7 +319,7 @@ def _check_pull_request_event(action: str, body: dict, log_context: dict) -> Tup | |||||||||
log_context["api_url"] = api_url | ||||||||||
if pull_request.get("draft", True) or pull_request.get("state") != "open": | ||||||||||
return invalid_result | ||||||||||
if action in ("review_requested", "synchronize") and pull_request.get("created_at") == pull_request.get("updated_at"): | ||||||||||
if action_type in ("review_requested", "synchronize") and pull_request.get("created_at") == pull_request.get("updated_at"): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code-quality): Use set when checking membership of a collection of literals (
Suggested change
|
||||||||||
# avoid double reviews when opening a PR for the first time | ||||||||||
return invalid_result | ||||||||||
return pull_request, api_url | ||||||||||
|
@@ -360,4 +360,4 @@ def start(): | |||||||||
|
||||||||||
|
||||||||||
if __name__ == '__main__': | ||||||||||
start() | ||||||||||
start() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider a more comprehensive solution for the 'action' vs 'action_type' naming conflict
The renaming of 'action' to 'action_type' addresses the immediate naming conflict but introduces inconsistency and potential confusion. Consider the following improvements:
A more thorough refactoring could improve code clarity and maintainability.