From 0ad237cace75a339a24f98a3d74baf8830944d78 Mon Sep 17 00:00:00 2001 From: Martin Moss Date: Thu, 30 Mar 2023 10:47:36 +0100 Subject: [PATCH] Updates and bugfixes --- .pre-commit-config.yaml | 12 ++++++------ gitfeatures/core.py | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bedb493..b428ca3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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$ diff --git a/gitfeatures/core.py b/gitfeatures/core.py index ef66a00..c9e6705 100644 --- a/gitfeatures/core.py +++ b/gitfeatures/core.py @@ -81,9 +81,18 @@ 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]) @@ -91,9 +100,11 @@ def _branch_func(branch_type, args): 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: @@ -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": @@ -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: