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
11 changes: 4 additions & 7 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ jobs:
- uses: actions/setup-python@v2
- run: pip install --upgrade pip wheel
- run: pip install bandit black codespell flake8 flake8-bugbear
flake8-comprehensions isort mypy pytest pyupgrade safety
flake8-comprehensions isort mypy pyupgrade safety
- run: bandit --recursive --skip B101,B404,B603 .
- run: black --check . || true
- run: black --diff .
- run: codespell --ignore-words-list="commitish"
- run: flake8 . --count --ignore=C408,E203,F841,W503 --max-complexity=10
--max-line-length=143 --show-source --statistics
- run: isort --check-only --profile black . || true
- run: pip install -r requirements.txt || pip install --editable . || true
- run: mkdir --parents --verbose .mypy_cache
- run: isort --check-only --profile black .
- run: pip install --editable .
- run: mypy --ignore-missing-imports --install-types --non-interactive .
- run: pytest . || true
- run: pytest --doctest-modules . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check
32 changes: 20 additions & 12 deletions cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import click
import collections
import enum
import os
import subprocess
import webbrowser
import re
import subprocess
import sys
import webbrowser

import click
import requests
import toml

from gidgethub import sansio

from . import __version__
Expand Down Expand Up @@ -167,7 +166,7 @@ def get_pr_url(self, base_branch, head_branch):
return f"https://github.com/{self.config['team']}/{self.config['repo']}/compare/{base_branch}...{self.username}:{head_branch}?expand=1"

def fetch_upstream(self):
""" git fetch <upstream> """
"""git fetch <upstream>"""
set_state(WORKFLOW_STATES.FETCHING_UPSTREAM)
cmd = ["git", "fetch", self.upstream, "--no-tags"]
self.run_cmd(cmd)
Expand All @@ -182,7 +181,7 @@ def run_cmd(self, cmd):
return output.decode("utf-8")

def checkout_branch(self, branch_name):
""" git checkout -b <branch_name> """
"""git checkout -b <branch_name>"""
cmd = [
"git",
"checkout",
Expand Down Expand Up @@ -219,7 +218,7 @@ def get_commit_message(self, commit_sha):
return message

def checkout_default_branch(self):
""" git checkout default branch """
"""git checkout default branch"""
set_state(WORKFLOW_STATES.CHECKING_OUT_DEFAULT_BRANCH)

cmd = "git", "checkout", self.config["default_branch"]
Expand All @@ -236,7 +235,7 @@ def status(self):
return self.run_cmd(cmd)

def cherry_pick(self):
""" git cherry-pick -x <commit_sha1> """
"""git cherry-pick -x <commit_sha1>"""
cmd = ["git", "cherry-pick", "-x", self.commit_sha1]
try:
click.echo(self.run_cmd(cmd))
Expand All @@ -261,7 +260,7 @@ def get_exit_message(self, branch):
"""

def amend_commit_message(self, cherry_pick_branch):
""" prefix the commit message with (X.Y) """
"""prefix the commit message with (X.Y)"""

commit_prefix = ""
if self.prefix_commit:
Expand All @@ -283,7 +282,7 @@ def amend_commit_message(self, cherry_pick_branch):
return updated_commit_message

def push_to_remote(self, base_branch, head_branch, commit_message=""):
""" git push <origin> <branchname> """
"""git push <origin> <branchname>"""
set_state(WORKFLOW_STATES.PUSHING_TO_REMOTE)

cmd = ["git", "push"]
Expand Down Expand Up @@ -607,7 +606,16 @@ class state:
@click.argument("branches", nargs=-1)
@click.pass_context
def cherry_pick_cli(
ctx, dry_run, pr_remote, abort, status, push, auto_pr, config_path, commit_sha1, branches
ctx,
dry_run,
pr_remote,
abort,
status,
push,
auto_pr,
config_path,
commit_sha1,
branches,
):
"""cherry-pick COMMIT_SHA1 into target BRANCHES."""

Expand Down
30 changes: 15 additions & 15 deletions cherry_picker/test.py → cherry_picker/test_cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
from collections import ChainMap
from unittest import mock

import pytest
import click
import pytest

from .cherry_picker import (
get_base_branch,
get_current_branch,
get_full_sha_from_short,
get_author_info_from_short_sha,
DEFAULT_CONFIG,
WORKFLOW_STATES,
CherryPicker,
InvalidRepoException,
CherryPickException,
normalize_commit_message,
DEFAULT_CONFIG,
get_sha1_from,
InvalidRepoException,
find_config,
load_config,
validate_sha,
from_git_rev_read,
reset_state,
set_state,
get_author_info_from_short_sha,
get_base_branch,
get_current_branch,
get_full_sha_from_short,
get_sha1_from,
get_state,
load_config,
load_val_from_git_cfg,
normalize_commit_message,
reset_state,
reset_stored_config_ref,
WORKFLOW_STATES,
set_state,
validate_sha,
)


Expand Down Expand Up @@ -945,4 +945,4 @@ def test_abort_cherry_pick_success(


def test_cli_invoked():
subprocess.check_call('cherry_picker --help'.split())
subprocess.check_call("cherry_picker --help".split())
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ filterwarnings =
error
junit_duration_report = call
junit_suite_name = cherry_picker_test_suite
testpaths = cherry_picker/test.py