Skip to content

Commit 1da73cf

Browse files
authored
Add compatibility note about Nu version (#1057)
This is my response for #1051 The syntax of this note is inspired by Rust _Cargo.toml_ and Python _pyproject.toml_.
1 parent 1e7fdd4 commit 1da73cf

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

custom-completions/git/git-completions.nu

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# nu-version: 0.102.0
2+
13
module git-completion-utils {
24
export const GIT_SKIPABLE_FLAGS = ['-v', '--version', '-h', '--help', '-p', '--paginate', '-P', '--no-pager', '--no-replace-objects', '--bare']
35

@@ -106,8 +108,8 @@ module git-completion-utils {
106108
let floating_remotes = $lines | filter { "\t" not-in $in and $in not-in $tracked_remotes }
107109
$floating_remotes | each {
108110
let v = $in | split row -n 2 '/' | get 1
109-
if $v != $current { [$v] } else []
110-
} | flatten
111+
if $v == $current { null } else $v
112+
}
111113
}
112114

113115
export def extract-mergable-sources [current: string]: list<string> -> list<record<value: string, description: string>> {
@@ -268,7 +270,7 @@ def "nu-complete git files" [] {
268270
def "nu-complete git built-in-refs" [] {
269271
[HEAD FETCH_HEAD ORIG_HEAD]
270272
}
271-
273+
272274
def "nu-complete git refs" [] {
273275
nu-complete git local branches
274276
| parse "{value}"

custom-completions/ssh/ssh-completions.nu

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# nu-version: 0.102.0
2+
13
export extern "ssh" [
24
destination?: string@"nu-complete ssh-host"
35
-4 # Forces ssh to use IPv4 addresses only.
@@ -41,11 +43,12 @@ module ssh-completion-utils {
4143
# │ 4 │ │
4244
# ╰───┴──────────────────────────────╯
4345
let host = $in
44-
let name = $host | get 0 | str trim | split row -r '\s+' | get 1
46+
let $first_line = try { $host | first | str trim } catch { null }
4547
# Don't accept blocks like "Host *"
46-
if ('*' in $name) {
48+
if ($first_line | is-empty) or '*' in $first_line {
4749
null
4850
} else {
51+
let name = $first_line | split row -r '\s+' | get 1
4952
# May not contain hostname
5053
match ($host | slice 1.. | find -ir '^\s*Hostname\s') {
5154
[] => null,
@@ -68,7 +71,7 @@ module ssh-completion-utils {
6871
includes: $include_lines
6972
}
7073
}
71-
74+
7275
}
7376

7477

0 commit comments

Comments
 (0)