Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions docs/guide-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Repo:
delete_closed: true

# Optional: sync draft PRs/MRs (default: true)
# regardless of this setting, a draft PR can still be synced manually with `approve`
sync_drafts: true

# Optional: post message when draft sync is disabled (default: true)
Expand Down Expand Up @@ -117,6 +118,8 @@ Replace `@{bot}` with your instance's bot user (e.g., `@lc-hubcast`) or use `/hu
### Approval
To securely mirror changes from external collaborators, approvals must be done via commenting on a PR review, ensuring that it is linked to a specific commit.

`approve` always syncs the reviewed commit, even for a draft PR where `sync_drafts` is disabled for the repo.

![A GitHub pull request review; the user has written a comment `@lc-hubcast approve` to sync the user's contributions.](/docs/img/approve-comment.png)

> [!NOTE]
Expand Down
6 changes: 4 additions & 2 deletions src/hubcast/web/github/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ async def sync_pr(
src_repo_private: bool,
want_sha: str,
default_branch: str,
force_sync_draft: bool = False, # allows draft PRs to be manually synced
) -> None:
"""Sync the git fork/branch referenced in a PR to GitLab.

Expand Down Expand Up @@ -490,7 +491,7 @@ async def sync_pr(
# validate the changes when the default branch config doesn't have issues
await validate_config_change(gh, changed_files, want_sha)

if not repo_config.sync_drafts and pull_request["draft"]:
if not force_sync_draft and not repo_config.sync_drafts and pull_request["draft"]:
if repo_config.sync_drafts_msg:
await gh.set_check_status(
want_sha,
Expand Down Expand Up @@ -669,7 +670,7 @@ async def respond_comment(
commit_sha = event.data["review"]["commit_id"]
pull_request = event.data["pull_request"]
src_repo_private = pull_request["head"]["repo"]["private"]
# sync the approved commit explicitly
# sync the approved commit explicitly even if sync_drafts is disabled
await sync_pr(
pull_request,
gh,
Expand All @@ -678,6 +679,7 @@ async def respond_comment(
src_repo_private,
want_sha=commit_sha,
default_branch=event.data["repository"]["default_branch"],
force_sync_draft=True,
)
plus_one = True
log.info(
Expand Down
Loading