Git Product home page Git Product logo

nu-git-manager's Introduction

nu-git-manager

A collection of Nushell tools to manage git repositories.

Table of content

๐Ÿ’ก what is nu-git-manager [toc]

like ghq, nu-git-manager aims at being a fully-featured repository manager, purely written in Nushell.

it provides two main modules:

  • nu-git-manager itself which ships the main gm command
  • nu-git-manager sugar which exports a bunch of Git-related tools, e.g. to help use the gh command or augment the capabilities of git

๐Ÿ”— requirements [toc]

  • Nushell 0.89.0
    • with Cargo and cargo install nu
  • git 2.34.1
    • with Pacman and pacman -S extra/git
    • with Nix and nix run nixpkgs#git
  • gh (optional) 2.29.0 (used by sugar gh)
    • with Pacman and pacman -S community/github-cli
    • with Nix and nix run nixpkgs#gh

โ™ป๏ธ installation [toc]

git clone https://github.com/amtoine/nu-git-manager
  • activate the toolkit module with use toolkit.nu
  • install the nu-git-manager and nu-git-manager-sugar packages
toolkit install
  • verify the installation after restarting Nushell
gm version

Note if you are using the latest stable release of Nushell, then you should install nu-git-manager from the main branch, i.e. by default.

if you want to use the latest and hotest builds of Nushell, either by building from source yourself or using the nightly builds, you might want to checkout the nightly branch and install from there. this alternative branch should contain all fixes and newest features from the latest versions of Nushell ๐Ÿ”ฅ

โš™๏ธ usage [toc]

in your config.nu you can add the following to load nu-git-manager modules:

# load the main `gm` command
use nu-git-manager *

# the following are non-essential modules
use nu-git-manager-sugar extra *              # augment `gm` with additional commands

Note
please have a look at the documentation of NGM for more modules and commands

then you have access to the whole nu-git-manager suite ๐Ÿฅณ

๐Ÿ™ getting help [toc]

please have a look at the documentation of NGM

โ— some ideas of advanced (?) usage [toc]

everytime i open a terminal, i use Tmux to manage sessions, switch between them, detach and reattach, quite a BLAZZINGLY FAST workflow for my taste ๐Ÿ˜

to achieve this, i use the tmux-sessionizer.nu script, again installed with Nupm ๐Ÿ‘Œ

then, in my Tmux config, i have a binding to

  1. list all my Git repositories
  2. fuzzy-pick one of them with the main command of tmux-sessionizer.nu
  3. create or reattach to the session associated with the repository
# ~/.config/tmux/tmux.conf

NUPM_HOME="~/.local/share/nupm"
TMUX_SESSIONIZER="$NUPM_HOME/scripts/tmux-sessionizer.nu"

bind-key -r t display-popup -E "nu --commands '
    use $NUPM_HOME/modules/nu-git-manager *;\
    $TMUX_SESSIONIZER (gm list --full-path) --short\
'"

nu-git-manager's People

Contributors

amtoine avatar melmass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nu-git-manager's Issues

a few preliminary ideas

Discussed in #1

Originally posted by amtoine April 23, 2023
for now i see four main ideas we have

def clone [
    owner: string
    repo: string
    --host: string = "github.com"
    --protocol: string = "https"
] {(
    git clone
        ({
            scheme: $protocol,
            host: $host,
            path: $"/($owner)/($repo)",
        } | url join)
        ($env.GIT_REPOS_HOME | path join $host $owner $repo)
)}

fatal: --bare and --origin foo options are incompatible.

Describe the bug

when Git has a version prior to 2.43.0, --bare and --origin are incompatible options of ^git clone, thus gm clone --bare will fail with

fatal: --bare and --origin foo options are incompatible.

How to reproduce

tk run {
    gm clone https://github.com/raphamorim/rio --bare
}

will fail on Ubuntu for instance.

Expected behavior

either

Configuration

> git --version
git version 2.34.1

Additional context

See commit 3b910d6 (22 Sep 2022) by Jeff King (peff).
(Merged by Junio C Hamano (gitster) in commit 7aeb0d4, 10 Oct 2022)

test coverage

in the long run, i think we need unit and integration tests, as much as possible ๐Ÿ‘

  • a CI to run them all: #27
  • unit tests: all the internals are tested
  • integration / end-to-end tests: make sure the gm commands work as expected with real repos
  • cover the modules of nu-git-manager-sugar

*GitHub* managment scripts

what do you think @melMass about adding some GitHub management scripts here? ๐Ÿ˜ฎ

i have my gh module and that little script i just wrote to help me review nushell PRs ๐Ÿ˜‹

def "nu-complete list-repos" [context: string] {
    let user = ($context | str replace 'gh\s*pr\s*open\s*' "" | split row " " | get 0)

    http get ({
        scheme: https,
        username: "",
        host: api.github.com,
        path: $"/orgs/($user)/repos",
        params: {
            sort: updated,
            per_page: 100,
            page: 1
        }
    } | url join)
    | select name description
    | rename value description
}

def "nu-complete gh-status" [] {[
    [value description];

    [failure "The CI does not pass."]
    [pending "The CI is currently running."]
    [success "All the CI jobs have passed."]
]}

def "nu-complete gh-review" [] {[
    [value description];

    [none "No review at all."]
    [changes-requested "There are changes to be applied."]
    [approved "The PR has been approved."]
]}

export def "gh pr open" [
    owner: string
    repo: string@"nu-complete list-repos"
    --draft: bool
    --ready: bool  # has precedence over `--draft`
    --status: string@"nu-complete gh-status"
    --review: string@"nu-complete gh-review"
] {
    let draft = (if $draft or $ready {
        $draft and (not $ready)
    })

    let query = [
        [is pr]
        [is open]
        [draft $draft]
        [status $status]
        [review $review]
    ]

    let url = ({
        scheme: https,
        host: github.com,
        path: $"/($owner)/($repo)/pulls",
        params: {
            q: (
                $query
                | where {|it| $it.1 != null}
                | each { str join "%3A" }
                | str join "+"
            )
        }
    } | url join)

    xdg-open $url
}

Note

  • added context-aware completion for repo
  • added --draft option
  • do not add draft to the query if neither --draft nor --ready are raised

i also have a GitHub gist management script here.

add diff when updating cache manually

let's say i update repos of my store manually:

  • i git init a repo called manual/foo
  • i git init a repo called manual/bar
  • i rm a repo called auto/baz

when i run gm update-cache to remove auto/baz from it and add manual/foo and manual/bar to it, i think it would be cool to have an output like the following:

> gm update-cache
updating cache... done
#โ”ฌโ”€โ”€โ”€nameโ”€โ”€โ”€โ”ฌstatusโ”€
0โ”‚manual/fooโ”‚added
1โ”‚manual/barโ”‚added
2โ”‚auto/baz  โ”‚removed
โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€

this implies that the signature of gm update-cache would change a bit from

"gm update-cache" []: nothing -> nothing

to

"gm update-cache" []: nothing -> table<name: string, status: string>

fix `path join`s

use path join "foo" "bar" instead of path join "foo/bar" to abstract path joining.

better errors for `gh` when not logged in

right now, the error is not that great when running gh ... being logged out ๐Ÿค”
and it does not fail in the sense that the LAST_EXIT_CODE is not set to 1 in that case ๐Ÿค”

an idea that looks to be working: add gh auth status at the start

remaining things: what happens when the user is

  • logged out: fails with You are not logged into any GitHub hosts. Run gh auth login to authenticate.
  • logged in: ??? => --logged-out option to query the API with http get

use a single test location

as per title, i would like to refactor the base directories of all the tests to be the same, to avoid messing around too much with the filesystem.

cannot clone *Suckless* software

description

nu-git-manager is not able to clone Suckless software.

reproduce

> gm clone git://git.suckless.org/st
Cloning into '/home/amtoine/documents/repos/git.suckless.org/st/st'...
fatal: repository 'https://git.suckless.org/st/st/' not found

expected

i would like to be able to do something like

> gm clone git://git.suckless.org/st --fetch git --push git

to specify to use the GIT protocol to at least fetch, you probably won't push there.

add a top-level `gm` command

i stumbled upon the following interesting structure

module foo {
    export def main [] { help foo }
    export def bar [] { "foo bar" }
}

where foo would do nothing but give the help of the module ๐Ÿ˜

> use foo
> foo bar
foo bar
> foo
Usage:
  > foo

Subcommands:
  foo bar -

Flags:
  -h, --help - Display the help message for this command

some ideas from `nu_scripts`

in the nushell/nu_scripts repo, we have the following files that could be interesting at some point

โ•ญโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ 0 โ”‚ aliases/git/nu_alias_git.nu                               โ”‚
โ”‚ 1 โ”‚ custom-completions/auto-generate/completions/git-sizer.nu โ”‚
โ”‚ 2 โ”‚ custom-completions/auto-generate/completions/git.nu       โ”‚
โ”‚ 3 โ”‚ custom-completions/auto-generate/completions/gitk.nu      โ”‚
โ”‚ 4 โ”‚ modules/git/git.nu                                        โ”‚
โ”‚ 5 โ”‚ modules/git/git_branch_cleanup.nu                         โ”‚
โ”‚ 6 โ”‚ modules/prompt/async_git_prompt/async-git-prompt.nu       โ”‚
โ”‚ 7 โ”‚ modules/prompt/panache-git.nu                             โ”‚
โ”‚ 8 โ”‚ modules/prompt/powerline/power_git.nu                     โ”‚
โ”‚ 9 โ”‚ sourced/cool-oneliners/git_gone.nu                        โ”‚
โ•ฐโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Note
generated with fd git | lines | find --invert themes before_v0.60 github gitlab custom-completions/git | find --invert --regex '/$'

there are also a bunch of things scattered around in my nu_scripts ๐Ÿ‘
especially

a bit of design: namespace and imports

i've been thinking a bit about the user experience of nu-git-manager.
with #26, i feel the command API is quite good and simple (:crossed_fingers:)

however, here i would like to talk about the way the library definitions are imported ๐Ÿ˜‹

cc/ @melMass

the namespace

i think all the commands from nu-git-manager should be subcommands of gm, to have

  • a single namespace
  • not clashing with external commands such as git or gh which can break external completers

imports

here is what i propose, the implementation is really a detail in the scope of this issue ๐Ÿ‘Œ

  • main commands
use nu-git-manager main [gm, "gm list", "gm clone", ...]
use nu-git-manager main *
  • Git commands from sugar
use nu-git-manager sugar git ["gm branch", "gm fetch", ...]
use nu-git-manager sugar git *
  • Github commands from sugar
use nu-git-manager sugar gh ["gm pr checkout", ...]
use nu-git-manager sugar gh *
  • all of sugar?
# would import all `gm branch`, `gm fetch`, `gm pr checkout`, ..., without `sugar` as prefix
use nu-git-manager sugar *
  • everything?
# would import all `gm clone`, `gm pr checkout`, ..., without `sugar` nor `main` as prefixes
use nu-git-manager *

`gm repo branches --clean` fails on checked out branch

Describe the bug

when using gm repo branches --clean when checked out on a dangling branch, the command will halt because git branch -D fails.

How to reproduce

tk run --clean {
    # setup the repo
    let repo = $nu.temp-path | path join foo
    if ($repo | path exists) {
        rm -f -r $repo
    }
    git init $repo
    cd $repo
    git checkout --orphan main
    git commit --allow-empty --no-gpg-sign --message "init"

    # create two branches and checkout the first one
    git branch bar
    git branch foo
    git checkout bar

    print $"dangling branches: (gm repo branches | where ($it.remotes | is-empty) | get branch)"
    gm repo branches --clean
}
Initialized empty Git repository in /tmp/foo/.git/
Switched to a new branch 'main'
[main (root-commit) e35547d] init
Switched to branch 'bar'
dangling branches: [bar, foo, main]
2023-12-06T16:33:36.290|INF|deleting branch `bar`
error: Cannot delete branch 'bar' checked out at '/tmp/foo'

Expected behavior

i expected gm repo branches --clean to skip branch bar and remove foo without an error.

Configuration

key value
version 0.87.1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2023-11-21 18:26:35 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins clipboard copy, clipboard paste, gstat, notify, nu_plugin_explore, query git

Additional context

No response

modules are missing extra usage in the documentation

Describe the bug

related to

How to reproduce

  1. look at the source of nu-git-manager => it has a usage and extra usage
  2. look at the documentation of the module => there is only the usage

Expected behavior

i expected to see the extra usage as well

Configuration

key value
version 0.89.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2024-01-11 18:20:14 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins clipboard copy, clipboard paste, gstat, nu_plugin_explore

Additional context

No response

refactor duplicate root stripping

i've noticed a bunch of

str replace (get-repo-store-path) '' | str trim --left --char "/"

or similar in the source base ๐Ÿค”

i think they should be refactored into something like path trim-root.

gm update-cache crashes nushell

This is what initially happens when you bring nu-git-manager out of the box...

In other words the first time installing it...

I started off by running

gm clone https://github.com/amtoine/nu-git-manager

And then got the message that "cache not found"

So I went ahead and ran the command

gm update-cache

And this is what happend --- nushell crashed and paniced with this error message

updating cache... Error:   ร— Deprecated option
    โ•ญโ”€[/Users/ma/j/tmp17/nu-git-manager/nu-git-manager/fs/store.nu:38:1]
 38 โ”‚     cd (get-repo-store-path)
 39 โ”‚     let heads: list<string> = glob "**/HEAD" --not [
    ยท                               โ”€โ”€โ”ฌโ”€
    ยท                                 โ•ฐโ”€โ”€ `glob --not {list<string>}` is deprecated and will be removed in 0.88.
 40 โ”‚             **/.git/**/refs/remotes/**/HEAD,
    โ•ฐโ”€โ”€โ”€โ”€
  help: Please use `glob --exclude {list<string>}` instead.


thread 'main' panicked at 'attempt to add with overflow', crates/nu-command/src/filters/range.rs:108:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This happens on both the main branch and the release of nushell 0.86

Both error out in the exact same spot...

https://github.com/nushell/nushell/blob/main/crates/nu-command/src/filters/range.rs#L108

the tests do not make sure users will be able to import `nu-git-manager`

Describe the bug

as per title

How to reproduce

  1. run
git checkout ea557bb8ebaed2bb40951ea434ab89712a718de5
  1. apply the following patch
diff --git a/src/nu-git-manager/mod.nu b/src/nu-git-manager/mod.nu
index 488854b..c3b82be 100644
--- a/src/nu-git-manager/mod.nu
+++ b/src/nu-git-manager/mod.nu
@@ -324,5 +324,7 @@ export def "gm remove" [
     check-cache-file $cache_file
     remove-from-cache $cache_file ($root | path join $repo_to_remove)
 
+    "foo" | path sanitize
+
     null
 }
  1. run use toolkit.nu; toolkit test => it runs just fine
  2. try to use ./src/nu-git-manager/ * and see the following error
Error: nu::parser::extra_positional

  ร— Extra positional argument.
     โ•ญโ”€[/home/amtoine/documents/repos/github.com/amtoine/nu-git-manager/src/nu-git-manager/mod.nu:326:1]
 326 โ”‚
 327 โ”‚     "foo" | path sanitize
     ยท                  โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€
     ยท                      โ•ฐโ”€โ”€ extra positional argument
 328 โ”‚
     โ•ฐโ”€โ”€โ”€โ”€
  help: Usage: path

Expected behavior

i expected the tests to fail

Configuration

key value
version 0.86.1
branch
commit_hash c1738620e33105a2622588561c8f3d1d69735678
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.71.1 (eb26296b5 2023-08-03)
rust_channel 1.71.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.71.1 (7f1d04c00 2023-07-29)
build_time 2023-11-08 22:48:06 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins jwalk, nu_plugin_explore

Additional context

No response

`unfold` is deprecated

Describe the bug

found the use of a deprecated command just after releasing 0.3.0 and trying out gm clean ๐Ÿ˜‹

unfold is going to be renamed generate very soon ๐Ÿ˜

How to reproduce

  1. tk run --clean { gm clone https://github.com/amtoine/nu-git-manager --depth 1 }
  2. tk run { gm update-cache; gm clean }
  3. see
Error:   ร— Deprecated option
   โ•ญโ”€[/home/amtoine/.local/share/nupm/modules/nu-git-manager/fs/dir.nu:6:1]
 6 โ”‚ export def clean-empty-directories-rec []: list<path> -> list<path> {
 7 โ”‚     let deleted = unfold $in {|directories|
   ยท                   โ”€โ”€โ”€โ”ฌโ”€โ”€
   ยท                      โ•ฐโ”€โ”€ `unfold` is deprecated and will be removed in 0.88.
 8 โ”‚         let next = $directories | each {|it|
   โ•ฐโ”€โ”€โ”€โ”€
  help: Please use `generate` instead.

Expected behavior

no deprecation warning

Configuration

key value
version 0.87.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2023-11-15 18:45:43 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins clipboard copy, clipboard paste, jwalk, nu_plugin_explore

Additional context

No response

detect when cloning a fork of a local repo

let's say i have already the nushell/nushell repo cloned.
when i gm clone https://github.com/amtoine/nushell, i.e. my fork of the Nushell repo, a new amtoine/nushell repo gets created in the store of nu-git-manager.

i would like gm to merge the two local copies, e.g. put everything in nushell/nushell and create two remotes

  • nushell which points to nushell/nushell
  • amtoine which points to amtoine/nushell

for my future self: a command to get the list of all the forks with their paths and root commit ๐Ÿ‘Œ

def get-forks []: nothing -> table<root: string, paths: list<string>> {
    gm list --full-path
        | each {{
            repo: $in,
            root: (^git -C $in rev-list HEAD | lines | last)
        }}
        | group-by root
        | transpose k v
        | where ($it.v | length) > 1
        | select k v.repo
        | rename --column { k: "root", v_repo: "paths" }
}
def is-grafted [repo?: path] {
    let repo = if $repo == null {
        pwd
    } else {
        if not ($repo | path exists) {
            error make {
                msg: $"(ansi red_bold)directory_not_found(ansi reset)"
                label: {
                    text: "no such directory"
                    start: (metadata $repo).span.start
                    end: (metadata $repo).span.end
                }
            }
        }

        $repo
    }

    let root_commit = ^git -C $repo rev-list HEAD | lines | last
    ^git -C $repo log --oneline --decorate $root_commit
        | parse --regex '[0-9a-f]+ \(grafted.*'
        | is-empty
        | not $in
}

improve getting started in the readme

Just dumping that here, as not everyone keep track of nushell version I think there should be a requirement section on the readme (could also be used to list other dependencies, like gh (optional).

Since a recent commit gm doesn't work on 0.79.1:

image

So I think it should also specify nushell 0.8.0+

squashing forks with remotes already setup fails

Describe the bug

as per title

How to reproduce

first run

tk run --clean {
    gm update-cache

    # clone two forks
    gm clone https://github.com/amtoine/nushell
    gm clone https://github.com/nushell/nushell

    # setup `nushell` as a remote of `amtoine`
    ^git -C ($env.GIT_REPOS_HOME | path join "github.com/amtoine/nushell") remote add nushell https://github.com/nushell/nushell

    # try to squash into `amtoine`
    gm squash-forks --non-interactive-preselect {
        8f3b273337b53bd86d5594d5edc9d4ad7242bd4c: "github.com/amtoine/nushell"
    }
}
deleted /tmp/nu-git-manager/repos
deleted /tmp/nu-git-manager/repos.cache
updating cache... done
Cloning into '/tmp/nu-git-manager/repos/github.com/amtoine/nushell'...
remote: Enumerating objects: 102625, done.
remote: Counting objects: 100% (102625/102625), done.
remote: Compressing objects: 100% (27930/27930), done.
remote: Total 102625 (delta 73950), reused 101765 (delta 73656), pack-reused 0
Receiving objects: 100% (102625/102625), 38.30 MiB | 21.49 MiB/s, done.
Resolving deltas: 100% (73950/73950), done.
updating cache... done
Cloning into '/tmp/nu-git-manager/repos/github.com/nushell/nushell'...
remote: Enumerating objects: 102194, done.
remote: Counting objects: 100% (102194/102194), done.
remote: Compressing objects: 100% (27838/27838), done.
remote: Total 102194 (delta 73627), reused 101309 (delta 73323), pack-reused 0
Receiving objects: 100% (102194/102194), 38.24 MiB | 12.13 MiB/s, done.
Resolving deltas: 100% (73627/73627), done.
Warning:   โš  cloning_fork
| this repo is a fork of 1 other repo because they share the same root commit: 8f3b273337b53bd86d5594d5edc9d4ad7242bd4c
| - github.com/amtoine/nushell
updating cache... done
error: remote nushell already exists.

Note
see the error at the bottom

now, if we list the repos, we still see nushell...

tk run { gm list }
โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
0โ”‚github.com/amtoine/nushell
1โ”‚github.com/nushell/nushell
โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Expected behavior

i expected tk run { gm list } to only return the amtoine fork.

Configuration

key value
version 0.87.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2023-11-15 18:45:43 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins clipboard copy, clipboard paste, jwalk, nu_plugin_explore

Additional context

No response

completion support coverage

in the long run, i'd like to have more external and custom completions inside both gm and sugar ๐Ÿ‘

in gm

  • custom completion on all the exported commands, e.g. host + user + project completion, possibly by pulling GitHub (? ๐Ÿ˜ฎ)

in sugar

external completions

  • the gh CLI command of GitHub in sugar completions gh: based on gh version 2.28.0 (2023-04-25)?
  • the usual git command
    • draw the full list of commands and options
    • write them all, even empty, for completeness
    • write custom completion for them
    • split the externals into modules, e.g. core, cherry, remote, worktree, ..., to allow importing only usefull commands more easily

custom completions

  • sugar git
  • sugar gist (removed)
  • sugar gh
  • sugar dotfiles (removed)

split the tests

i would like to split the tests

  • tests internals from the current tests
    • maybe further splitting this as well
  • tests gm from #48
    • maybe a sub tests gm clone for all the clone tests

cannot remove a repo when inside of it

Describe the bug

as per title

How to reproduce

tk run --clean {
    gm update-cache

    gm clone --depth 1 https://github.com/amtoine/nu-git-manager
    let repo = gm list --full-path | find nu-git-manager | get 0
    cd $repo
    gm remove --no-confirm nu-git-manager
}

will give

Error:   ร— Cannot remove any parent directory
     โ•ญโ”€[/home/amtoine/.local/share/nupm/modules/nu-git-manager/mod.nu:433:1]
 433 โ”‚
 434 โ”‚     rm --recursive --force --verbose $repo_to_remove
     ยท                                      โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€
     ยท                                             โ•ฐโ”€โ”€ cannot remove any parent directory
 435 โ”‚
     โ•ฐโ”€โ”€โ”€โ”€

Expected behavior

i expected either the repo to be removed or at least a nice error

Configuration

key value
version 0.89.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2024-01-11 18:20:14 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins clipboard copy, clipboard paste, gstat, nu_plugin_explore, query git

Additional context

No response

`gm remove` does not remove empty directories

Describe the bug

when using gm remove empty parent directories are left there untouched.
this could break manual scripts that try to list stuff in the store...

How to reproduce

tk run --clean {
    gm update-cache
    gm clone https://github.com/amtoine/nu-git-manager --depth 1
    gm remove --no-confirm nu-git-manager

    print ($env.GIT_REPOS_HOME | path join "github.com/amtoine" | path exists)
    print ($env.GIT_REPOS_HOME | path join "github.com/amtoine" | ls $in | is-empty)
}

will print

true
true

Expected behavior

i expected gm remove to clean the empty mess and thus the repro snippet above to print false twice.

Configuration

key value
version 0.86.1
branch main
commit_hash 0ca8fcf58c02bef31f1eb65e001d71f5648b3b35
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.71.1 (eb26296b5 2023-08-03)
rust_channel 1.71.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.71.1 (7f1d04c00 2023-07-29)
build_time 2023-11-02 17:56:54 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins jwalk, nu_plugin_explore

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.