Skip to content

Commit

Permalink
Updates and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martyzz1 committed Mar 30, 2023
1 parent 218429a commit 0ad237c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
# - id: check-docstring-first
Expand All @@ -29,23 +29,23 @@ repos:
- id: requirements-txt-fixer
args: [requirements-dev.txt]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
rev: v1.30.0
hooks:
- id: yamllint
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
exclude: .+\/migrations.*\.py$
args: [-t, py37, -l, "119"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
exclude: .+\/migrations.*\.py$
Expand Down
22 changes: 16 additions & 6 deletions gitfeatures/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,30 @@ def finish_feature(name, prefix):
def _branch_func(branch_type, args):
if len(args) > 0 and args[0] == "new":
prefix = ""
now = datetime.datetime.now()
date = now.date()
date_string = date.strftime("%Y%m%d")

if len(args) == 2:
prefix = args[1]
name = "{}_{}".format(str(datetime.date.today()), prefix)
else:
time = now.time()
time_string = time.strftime("%H%M%S")
prefix = time_string

name = "{}_{}".format(date_string, prefix)
new_branch = _get_branch_name(branch_type, name)

_call(["git", "checkout", "-b", new_branch])
_call(["git", "push", "-u", "origin", new_branch + ":" + new_branch])

branches = _get_branches(branch_type)
if len(branches) > 3:
print(f"you have more than 3 {branch_type} branches, shall I delete the eldest one? [y/n]") # noqa
branch = branches[0]
print(
f"you have more than 3 {branch_type} branches, shall I delete the eldest one ({branch})? [y/n]"
) # noqa
if input().lower() == "y":
branch = branches[0]
_call(["git", "push", "origin", "--delete", branch])
_call(["git", "branch", "-D", branch])
else:
Expand Down Expand Up @@ -174,7 +185,6 @@ def pullrequest(args):


def _get_pullrequest_url(name, branch):

if repo == "github":
url = "https://github.com/" + name + "/pull/new/" + branch
elif repo == "bitbucket":
Expand All @@ -201,14 +211,14 @@ def _get_branches(branch_type):
try:
branch_list = (
check_output(
f"git branch -r | grep -e '\/{branch_type}_\d\d\d\d\d\d\d\d'", # noqa
f"git branch -r | grep -e '\/{branch_type}{seperator}\d\d\d\d\d\d\d\d'", # noqa
shell=True,
)
.decode("utf-8")
.strip()
)
branch_list = branch_list.split("\n")
branch_list = list(map(lambda it: it.split("/")[1].strip(), branch_list))
branch_list = list(map(lambda it: it.split("/", 1)[1].strip(), branch_list))

return branch_list
except CalledProcessError:
Expand Down

0 comments on commit 0ad237c

Please sign in to comment.