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
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ all: deps lint man package install
deps:
$(PYTHON) -m pip install .[dev]

# Format using black
BLACK_CMD=$(PYTHON) -m black --line-length 100 -t py38 --preview --exclude "build/.*|\.eggs/.*"
ISORT_CMD=$(PYTHON) -m isort --profile black --py 38
# Format using ruff
RUFF_CMD=$(PYTHON) -m ruff
format:
$(BLACK_CMD) .
$(ISORT_CMD) .
$(RUFF_CMD) format .
$(RUFF_CMD) check --select I --fix .

# Check formatting using black
# Check formatting using ruff
check_format:
$(BLACK_CMD) --check --diff .
$(ISORT_CMD) --check --diff .
$(RUFF_CMD) format --check --diff .
$(RUFF_CMD) check --select I --diff .

MYPY_COMMAND=$(PYTHON) -m mypy --show-error-codes
check_types:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tool.ruff]
line-length = 100
target-version = "py38"
extend-exclude = ["build", ".eggs"]

[tool.ruff.lint.isort]
known-first-party = ["revup"]
2 changes: 1 addition & 1 deletion revup/forge_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ async def forge_connection(
await forge.close()
else:
raise RevupUsageException(
f'Unrecognized forge URL "{args.forge_url}". ' "Currently only GitHub is supported."
f'Unrecognized forge URL "{args.forge_url}". Currently only GitHub is supported.'
)
10 changes: 6 additions & 4 deletions revup/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,12 @@ async def find_remote_branches(
if prune_old:
fork_with_main = await self.fork_point(commit, f"{self.remote_name}/{self.main_branch}")
# A branch that doesn't contain the fork with main must be too old
args.extend((
"--contains",
fork_with_main,
))
args.extend(
(
"--contains",
fork_with_main,
)
)

RE_REMOTE_REF = re.compile(r"^refs/remotes/(?P<branch>.*)$")
ret: List[str] = []
Expand Down
104 changes: 60 additions & 44 deletions revup/github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,17 @@ async def create_pull_requests(self, repo_id: str, prs: List[PrInfo]) -> None:
if self.fork_info.owner == self.repo_info.owner
else f"{self.fork_info.owner}:{pr.headRef}"
)
inputs.append({
"baseRefName": pr.baseRef,
"body": pr.body,
"clientMutationId": "revup",
"headRefName": headRef,
"repositoryId": repo_id,
"title": pr.title,
"draft": pr.is_draft,
})
inputs.append(
{
"baseRefName": pr.baseRef,
"body": pr.body,
"clientMutationId": "revup",
"headRefName": headRef,
"repositoryId": repo_id,
"title": pr.title,
"draft": pr.is_draft,
}
)
inputs_args = _get_args_dict(inputs, "pr")
prs_out = _get_result_args(len(inputs), "pr_out")

Expand Down Expand Up @@ -506,52 +508,66 @@ async def update_pull_requests(self, prs: List[PrUpdate]) -> None:
inputs.append(update_dict)

if pr.label_ids:
labels.append({
"labelIds": list(pr.label_ids),
"clientMutationId": "revup",
"labelableId": pr.id,
})
labels.append(
{
"labelIds": list(pr.label_ids),
"clientMutationId": "revup",
"labelableId": pr.id,
}
)

if pr.reviewer_ids or pr.reviewer_team_ids:
reviewers.append({
"userIds": list(pr.reviewer_ids),
"teamIds": list(pr.reviewer_team_ids),
"clientMutationId": "revup",
"pullRequestId": pr.id,
"union": True,
})
reviewers.append(
{
"userIds": list(pr.reviewer_ids),
"teamIds": list(pr.reviewer_team_ids),
"clientMutationId": "revup",
"pullRequestId": pr.id,
"union": True,
}
)
if pr.assignee_ids:
assignees.append({
"assigneeIds": list(pr.assignee_ids),
"clientMutationId": "revup",
"assignableId": pr.id,
})
assignees.append(
{
"assigneeIds": list(pr.assignee_ids),
"clientMutationId": "revup",
"assignableId": pr.id,
}
)

if pr.is_draft is not None:
if pr.is_draft:
convert_to_draft.append({
"clientMutationId": "revup",
"pullRequestId": pr.id,
})
convert_to_draft.append(
{
"clientMutationId": "revup",
"pullRequestId": pr.id,
}
)
else:
convert_from_draft.append({
"clientMutationId": "revup",
"pullRequestId": pr.id,
})
convert_from_draft.append(
{
"clientMutationId": "revup",
"pullRequestId": pr.id,
}
)

for c in pr.comments:
if c.id:
edit_comments.append({
"body": c.text,
"clientMutationId": "revup",
"id": c.id,
})
edit_comments.append(
{
"body": c.text,
"clientMutationId": "revup",
"id": c.id,
}
)
else:
comments.append({
"body": c.text,
"clientMutationId": "revup",
"subjectId": pr.id,
})
comments.append(
{
"body": c.text,
"clientMutationId": "revup",
"subjectId": pr.id,
}
)

inputs_args = _get_args_dict(inputs, "pr")
prs_out = _get_result_args(len(inputs), "pr_out")
Expand Down
10 changes: 6 additions & 4 deletions revup/topic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,12 @@ async def mark_rebases(self, skip_rebase: bool) -> None:
# Check rebase by applying each local commit onto the remote parent
# and comparing the resulting tree to the remote tree.
is_rebase = len(review.remote_commits) == len(topic.original_commits) and all(
await asyncio.gather(*(
self.git_ctx.commits_are_equivalent(local, remote)
for local, remote in zip(topic.original_commits, review.remote_commits)
))
await asyncio.gather(
*(
self.git_ctx.commits_are_equivalent(local, remote)
for local, remote in zip(topic.original_commits, review.remote_commits)
)
)
)
# This review is a "complete rebase" iff all commit diffs and metadata match
review.is_pure_rebase = is_rebase and all(
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ include_package_data=True

[options.extras_require]
dev =
black==24.1.1
isort
ruff==0.15.16
pylint==3.2.7
mypy==1.13.0
build
Expand Down
6 changes: 3 additions & 3 deletions tests/fake_forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ async def update_pull_requests(self, prs: List[PrUpdate]) -> None:
# baseRef must differ from current if specified
if update.baseRef is not None:
assert update.baseRef, "baseRef cannot be empty string"
assert (
update.baseRef != target_pr.headRef
), f"cannot set baseRef to headRef ({update.baseRef})"
assert update.baseRef != target_pr.headRef, (
f"cannot set baseRef to headRef ({update.baseRef})"
)

# title cannot be empty if specified
if update.title is not None:
Expand Down
Loading