~rjarry/dlrepo

dlrepo: cli: ask before deleting branch or tag v1 NEEDS REVISION

Julien Floret: 1
 cli: ask before deleting branch or tag

 1 files changed, 24 insertions(+), 0 deletions(-)
#963532 .build.yml success
Le ven. 31 mars 2023 à 21:27, Robin Jarry <robin@jarry.cc> a écrit :
Next
Julien Floret, Apr 03, 2023 at 14:27:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rjarry/dlrepo/patches/40024/mbox | git am -3
Learn more about email & git

[PATCH dlrepo] cli: ask before deleting branch or tag Export this patch

Ask confirmation before deleting a whole branch or tag.
Add a "-f/--force" global argument that can be used to bypass the
confirmation.

Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
---
 dlrepo-cli | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/dlrepo-cli b/dlrepo-cli
index 13fa16f5157b..4daef667351d 100755
--- a/dlrepo-cli
+++ b/dlrepo-cli
@@ -72,6 +72,14 @@ def main():
        Only applies to non-binary data.
        """,
    )
    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        help="""
        Do not ask for confirmation.
        """,
    )
    sub = parser.add_subparsers(title="sub-command help", metavar="SUB_COMMAND")
    sub.required = True

@@ -139,6 +147,18 @@ def job_param(value):
    return (match.group(1), match.group(2))


# --------------------------------------------------------------------------------------
def ask(question, force=False):
    if force:
        return
    while True:
        response = input(f"{question}? [y/N] ")
        if response.lower() in ("y", "yes"):
            return
        if response.lower() in ("", "n", "no"):
            raise KeyboardInterrupt()


# --------------------------------------------------------------------------------------
@sub_command(
    Arg("branch", metavar="BRANCH", help="the branch name"),
@@ -463,8 +483,12 @@ def delete(args):
            if args.force:
                params["force"] = "true"
            url = os.path.join("branches", args.branch, args.tag) + "/"
            full_url = client.make_url(url)
            ask(f"Delete whole tag {full_url}", args.force)
    else:
        url = os.path.join("branches", args.branch) + "/"
        full_url = client.make_url(url)
        ask(f"Delete whole branch {full_url}", args.force)
    client.delete(url, params)


-- 
2.30.2
dlrepo/patches/.build.yml: SUCCESS in 1m36s

[cli: ask before deleting branch or tag][0] from [Julien Floret][1]

[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/40024
[1]: mailto:julien.floret@6wind.com

✓ #963532 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/963532
Julien Floret, Mar 27, 2023 at 16:53: