Skip to content

Commit

Permalink
bump to 0.5.0 (#159)
Browse files Browse the repository at this point in the history
- rebase the changes from nightly
- bump
  - NGM to `0.5.0`
  - Nushell to `0.89.0`
  - Nupm to nushell/nupm#57

> **Note**
> ```nushell
> git diff nightly
> ```
> correctly gives
> ```diff
> diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
> index 9fc71c9..57437cb 100644
> --- a/.github/workflows/ci.yml
> +++ b/.github/workflows/ci.yml
> @@ -13,10 +13,10 @@ jobs:
>    tests:
>      uses: ./.github/workflows/nupm-tests.yml
>      with:
> -      nu_version: "0.88.1"
> -      nupm_revision: "6a9618fa21453bca4000ac33707b7aace0da35c7"
> +      nu_version: "0.89.0"
> +      nupm_revision: "66e2eaa848e3f72c1b4a841f26f4dc7efc4fedb9"
>  
>    documentation:
>      uses: ./.github/workflows/check-documentation.yml
>      with:
> -      nu_version: "0.88.1"
> +      nu_version: "0.89.0"
> diff --git a/pkgs/nu-git-manager-sugar/nupm.nuon
b/pkgs/nu-git-manager-sugar/nupm.nuon
> index 974b12f..bee1672 100644
> --- a/pkgs/nu-git-manager-sugar/nupm.nuon
> +++ b/pkgs/nu-git-manager-sugar/nupm.nuon
> @@ -1,6 +1,6 @@
>  {
>      name: "nu-git-manager-sugar"
> -    version: 0.4.0
> +    version: 0.5.0
> description: "A collection of extra Nushell tools to manage `git`
repositories."
> documentation:
"https://github.com/amtoine/nu-git-manager/blob/main/README.md"
>      maintainers: [
> @@ -9,7 +9,7 @@
>      ]
> license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
>      dependencies: {
> -        nushell: 0.88.1
> +        nushell: 0.89.0
>          git: 2.40.1
>          optionals: {
>              "sugar gh": {
> diff --git a/pkgs/nu-git-manager/nupm.nuon
b/pkgs/nu-git-manager/nupm.nuon
> index e17af38..9fa9895 100644
> --- a/pkgs/nu-git-manager/nupm.nuon
> +++ b/pkgs/nu-git-manager/nupm.nuon
> @@ -1,6 +1,6 @@
>  {
>      name: "nu-git-manager"
> -    version: 0.4.0
> +    version: 0.5.0
> description: "A collection of Nushell tools to manage `git`
repositories."
> documentation:
"https://github.com/amtoine/nu-git-manager/blob/main/README.md"
>      maintainers: [
> @@ -9,7 +9,7 @@
>      ]
> license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
>      dependencies: {
> -        nushell: 0.88.1
> +        nushell: 0.89.0
>          git: 2.40.1
>      }
>      type: "module"
> ```
  • Loading branch information
amtoine authored Jan 21, 2024
1 parent 937f4a8 commit ba3a88d
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 58 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
tests:
uses: ./.github/workflows/nupm-tests.yml
with:
nu_version: "0.88.1"
nupm_revision: "6a9618fa21453bca4000ac33707b7aace0da35c7"
nu_version: "0.89.0"
nupm_revision: "66e2eaa848e3f72c1b4a841f26f4dc7efc4fedb9"

documentation:
uses: ./.github/workflows/check-documentation.yml
with:
nu_version: "0.88.1"
nu_version: "0.89.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../../git/lib/style.nu [color]
use style.nu [color]

# give the revision of the repo you're in
#
Expand Down Expand Up @@ -40,7 +40,7 @@ use ../../git/lib/style.nu [color]
# │ type │ detached │
# ╰──────┴──────────╯
export def get-revision [
--short-hash: bool # print the hash of a detached HEAD in short format
--short-hash # print the hash of a detached HEAD in short format
]: nothing -> record<name: string, hash: string, type: string> {
let tag = do -i {
^git describe HEAD --tags
Expand Down Expand Up @@ -119,3 +119,4 @@ export def get-status [
untracked: ($status | parse --regex '^\?\? (?<file>.*)' | get file),
}
}

3 changes: 3 additions & 0 deletions pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export module git.nu
export module prompt.nu
export module style.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ../../git/lib/lib.nu [get-revision, git-action, get-status]
use ../../git/lib/style.nu [color, simplify-path]
use git [get-revision, git-action, get-status]
use style.nu [color, simplify-path]

# /!\ the PWD will be sanitized
export def get-left-prompt [duration_threshold: duration]: nothing -> string {
Expand Down Expand Up @@ -31,7 +31,7 @@ export def get-left-prompt [duration_threshold: duration]: nothing -> string {
}

let git_branch_segment = if $is_git_repo {
let revision = get-revision --short-hash true
let revision = get-revision --short-hash
let pretty_branch_tokens = match $revision.type {
"branch" => [
($revision.name | color {fg: "yellow", attr: "ub"}),
Expand Down
7 changes: 5 additions & 2 deletions pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use std log

use ../git/lib/lib.nu [get-status]
module lib/
use lib git [get-status]

use ../completions/nu-complete.nu [
use completions [
GIT_QUERY_TABLES, GIT_STRATEGIES, git-query-tables, get-remotes, get-branches, get-strategies
]

export module prompt.nu

# get the commit hash of any revision
#
# ## Examples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../git/lib/prompt.nu [get-left-prompt]
use lib prompt [get-left-prompt]

const DEFAULT_PROMPT_INDICATORS = {
plain: "> ",
Expand Down
4 changes: 4 additions & 0 deletions pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module completions.nu
export module extra.nu
export module git/
export module github.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
name: "nu-git-manager-sugar"
version: 0.4.0
version: 0.5.0
description: "A collection of extra Nushell tools to manage `git` repositories."
documentation: "https://github.com/amtoine/nu-git-manager/blob/main/README.md"
maintainers: [
Expand All @@ -9,7 +9,7 @@
]
license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
dependencies: {
nushell: 0.88.1
nushell: 0.89.0
git: 2.40.1
optionals: {
"sugar gh": {
Expand Down
10 changes: 5 additions & 5 deletions pkgs/nu-git-manager-sugar/tests/git.nu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/ git [
"gm repo branch wipe"
"gm repo compare"
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"]
use ../../../tests/common/setup.nu [get-random-test-dir]

def --env init-repo-and-cd-into []: nothing -> path {
Expand Down Expand Up @@ -369,18 +369,18 @@ export def branch-compare [] {
}

export module prompt {
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu [
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib git [
get-revision, git-action
]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu [
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib prompt [
get-left-prompt
]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/style.nu [
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib style [
simplify-path
]

def "assert revision" [expected: record] {
let actual = get-revision --short-hash true
let actual = get-revision --short-hash
assert equal $actual $expected
}

Expand Down
2 changes: 2 additions & 0 deletions pkgs/nu-git-manager-sugar/tests/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std assert
use ../../../tests/common/import.nu ["assert imports"]
use ../../../tests/common/setup.nu [get-random-test-dir]

export module git.nu

const MODULE = "nu-git-manager-sugar"

export module imports {
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion pkgs/nu-git-manager/nu-git-manager/fs/cache.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use path.nu "path sanitize"
use ../git/repo.nu [is-grafted]

# get the path to the cache of the local store of repos
#
Expand Down
4 changes: 4 additions & 0 deletions pkgs/nu-git-manager/nu-git-manager/fs/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export module cache.nu
export module dir.nu
export module path.nu
export module store.nu
2 changes: 2 additions & 0 deletions pkgs/nu-git-manager/nu-git-manager/git/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export module repo.nu
export module url.nu
2 changes: 1 addition & 1 deletion pkgs/nu-git-manager/nu-git-manager/git/repo.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../error/error.nu [throw-error]
use ../error.nu [throw-error]

# tell if a local repository has been grafted
#
Expand Down
6 changes: 3 additions & 3 deletions pkgs/nu-git-manager/nu-git-manager/git/url.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../fs/path.nu "path sanitize"
use ../fs path "path sanitize"

# parse the URL of a Git repo
#
Expand Down Expand Up @@ -28,8 +28,8 @@ export def parse-git-url []: string -> record<host: string, owner: string, group
}

{
owner: $owner,
group: $group,
owner: ($owner | default ""),
group: ($group | default ""),
repo: ($tokens | last)
}
}
Expand Down
29 changes: 17 additions & 12 deletions pkgs/nu-git-manager/nu-git-manager/mod.nu
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
use std log

use fs/store.nu [get-repo-store-path, list-repos-in-store]
use fs/cache.nu [
module completions.nu
module error.nu
module fs/
module git/

use fs store [get-repo-store-path, list-repos-in-store]
use fs cache [
get-repo-store-cache-path, check-cache-file, add-to-cache, remove-from-cache, open-cache,
save-cache, clean-cache-dir
]
use fs/dir.nu [clean-empty-directories-rec]
use fs/path.nu ["path sanitize", "path remove-prefix"]
use git/url.nu [parse-git-url, get-fetch-push-urls]
use git/repo.nu [is-grafted, get-root-commit, list-remotes]
use error/error.nu [throw-error, throw-warning]
use fs dir [clean-empty-directories-rec]
use fs path ["path sanitize", "path remove-prefix"]
use git url [parse-git-url, get-fetch-push-urls]
use git repo [is-grafted, get-root-commit, list-remotes]
use error.nu [throw-error, throw-warning]

use completions/nu-complete.nu
use completions

# manage your Git repositories with the main command of NGM
#
Expand Down Expand Up @@ -84,8 +89,8 @@ export def "gm clone" [
url: string # the URL to the repository to clone, supports HTTPS and SSH links, as well as references ending in `.git` or starting with `git@`
--remote: string = "origin" # the name of the remote to setup
--ssh # setup the remote to use the SSH protocol both to FETCH and to PUSH
--fetch: string@"nu-complete git-protocols" # setup the FETCH protocol explicitely, will overwrite `--ssh` for FETCH
--push: string@"nu-complete git-protocols" # setup the PUSH protocol explicitely, will overwrite `--ssh` for PUSH
--fetch: string@"completions git-protocols" # setup the FETCH protocol explicitely, will overwrite `--ssh` for FETCH
--push: string@"completions git-protocols" # setup the PUSH protocol explicitely, will overwrite `--ssh` for PUSH
--bare # clone the repository as a "bare" project
--depth: int # the depth at which to clone the repository
]: nothing -> nothing {
Expand All @@ -109,7 +114,7 @@ export def "gm clone" [
}
}

let urls = get-fetch-push-urls $repository $fetch $push $ssh
let urls = get-fetch-push-urls $repository ($fetch | default "") ($push | default "") $ssh

mut args = [$urls.fetch $local_path --origin $remote]
if $depth != null {
Expand All @@ -134,7 +139,7 @@ export def "gm clone" [
}
}

^git clone $args
^git clone ...$args

^git -C $local_path remote set-url $remote $urls.fetch
^git -C $local_path remote set-url $remote --push $urls.push
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
name: "nu-git-manager"
version: 0.4.0
version: 0.5.0
description: "A collection of Nushell tools to manage `git` repositories."
documentation: "https://github.com/amtoine/nu-git-manager/blob/main/README.md"
maintainers: [
Expand All @@ -9,7 +9,7 @@
]
license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
dependencies: {
nushell: 0.88.1
nushell: 0.89.0
git: 2.40.1
}
type: "module"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/nu-git-manager/tests/gm.nu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std assert

use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [list-remotes]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"]
use ../../../pkgs/nu-git-manager/nu-git-manager/git repo [list-remotes]
use ../../../pkgs/nu-git-manager/nu-git-manager/ *

use ../../../tests/common/setup.nu [get-random-test-dir]
Expand Down
32 changes: 17 additions & 15 deletions pkgs/nu-git-manager/tests/mod.nu
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
use std assert

use ../../../pkgs/nu-git-manager/nu-git-manager/git/url.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/git url [
parse-git-url, get-fetch-push-urls
]
use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/git repo [
is-grafted, get-root-commit, list-remotes
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/store.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/fs store [
get-repo-store-path, list-repos-in-store
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/cache.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/fs cache [
get-repo-store-cache-path, check-cache-file, add-to-cache, remove-from-cache, open-cache,
save-cache, clean-cache-dir
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/fs path [
"path sanitize", "path remove-prefix", "path remove-trailing-path-sep"
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/dir.nu [clean-empty-directories-rec]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs dir [clean-empty-directories-rec]

use ../../../tests/common/setup.nu [get-random-test-dir]

export module gm.nu

export module path {
export def sanitization [] {
assert equal ('\foo\bar' | path sanitize) "/foo/bar"
Expand All @@ -43,15 +45,15 @@ export def git-url-parsing [] {
let cases = [
[input, host, owner, group, repo];

["https://github.com/foo/bar", "github.com", "foo", null, "bar"],
["https://github.com/foo/bar.git", "github.com", "foo", null, "bar"],
["https://github.com/foo/bar/tree/branch/file", "github.com", "foo", null, "bar"],
["ssh://github.com/foo/bar", "github.com", "foo", null, "bar"],
["[email protected]:foo/bar", "github.com", "foo", null, "bar"],
["https://gitlab.com/foo/bar", "gitlab.com", "foo", null, "bar"],
["[email protected]:foo/bar", "gitlab.com", "foo", null, "bar"],
["https://github.com/foo/bar", "github.com", "foo", "", "bar"],
["https://github.com/foo/bar.git", "github.com", "foo", "", "bar"],
["https://github.com/foo/bar/tree/branch/file", "github.com", "foo", "", "bar"],
["ssh://github.com/foo/bar", "github.com", "foo", "", "bar"],
["[email protected]:foo/bar", "github.com", "foo", "", "bar"],
["https://gitlab.com/foo/bar", "gitlab.com", "foo", "", "bar"],
["[email protected]:foo/bar", "gitlab.com", "foo", "", "bar"],
["[email protected]:foo/bar/baz/brr", "gitlab.com", "foo", "bar/baz", "brr"],
["git://git.suckless.org/st", "git.suckless.org", null, null, "st"],
["git://git.suckless.org/st", "git.suckless.org", "", "", "st"],
]

for case in $cases {
Expand Down Expand Up @@ -202,7 +204,7 @@ export def cache-manipulation [] {
root_hash: "",
}

def "assert cache" [cache: list<string>]: nothing -> nothing {
def "assert cache" [cache: list<any>]: nothing -> nothing {
let actual = open-cache $CACHE | update path { path remove-prefix (pwd | path sanitize) }
let expected = $cache
| each {|it|
Expand Down
2 changes: 1 addition & 1 deletion tests/common/setup.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"]

# return the path to a random test directory
#
Expand Down
8 changes: 5 additions & 3 deletions toolkit.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std repeat

# NOTE: this will likely get replaced by Nupm workspaces in the future
def list-modules-of-workspace []: nothing -> list<string> {
ls pkgs/**/package.nuon
ls pkgs/**/nupm.nuon
| insert pkg {|it| open $it.name | get name }
| each {|it| $it.name | path dirname | path join $it.pkg }
}
Expand Down Expand Up @@ -114,11 +114,13 @@ export def "run" [
}

let sugar_imports = if $sugar != null {
$sugar | each { $"use ./src/nu-git-manager-sugar ($in) *" }
$sugar | each { $"use ./pkgs/nu-git-manager-sugar/nu-git-manager-sugar ($in) *" }
} else {
[]
}
let imports = $sugar_imports | prepend "use ./src/nu-git-manager *" | str join "\n"
let imports = $sugar_imports
| prepend "use ./pkgs/nu-git-manager/nu-git-manager *"
| str join "\n"

let nu_args = [
--env-config $env_file
Expand Down

0 comments on commit ba3a88d

Please sign in to comment.