nu: Add git sha command
This commit is contained in:
@@ -18,3 +18,26 @@ def gitfixremote [
|
||||
print $"Unknown host: ($parsed.host)"
|
||||
}
|
||||
}
|
||||
|
||||
def "git sha" [
|
||||
--no-copy(-c), # don't copy to clipboard
|
||||
--full(-f), # output the complete sha
|
||||
]: nothing -> record {
|
||||
mut sha = (git show -q | lines | parse "commit {sha}" | first);
|
||||
|
||||
if ($sha | is-empty) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sha = $sha.sha
|
||||
|
||||
if not $full {
|
||||
$sha = ($sha | str substring 0..7)
|
||||
}
|
||||
|
||||
if not $no_copy {
|
||||
$sha | pbc
|
||||
}
|
||||
|
||||
$sha
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user