Skip to content

Commit

Permalink
add a few examples to nu-git-manager-sugar git commands (#107)
Browse files Browse the repository at this point in the history
as per title
  • Loading branch information
amtoine committed Nov 23, 2023
1 parent c3ad086 commit a3ca2a1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/nu-git-manager-sugar/git.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
use std log

# get the commit hash of any revision
#
# # Examples
# get the commit hash of the currently checked out revision
# > gm repo get commit
#
# get the commit hash of the main branch
# > gm repo get commit main
export def "gm repo get commit" [
revision: string = "HEAD" # the revision to get the hash of
]: nothing -> string {
Expand All @@ -13,6 +20,11 @@ def repo-root [] {
}

# go to the root of the repository from anywhere in the worktree
#
# # Examples
# go back to the root of a repo
# > cd foo/bar/baz; gm repo goto root; print (pwd)
# /path/to/repo
export def --env "gm repo goto root" []: nothing -> nothing {
cd (repo-root)
}
Expand Down Expand Up @@ -79,6 +91,12 @@ export def "gm repo is-ancestor" [
}

# get the list of all the remotes in the current repository
# # Examples
# list all the remotes in a default `nu-git-manager` repo
# > gm repo remote list
# #┬remote┬──────────────────fetch──────────────────┬─────────────────push──────────────────
# 0│origin│https://github.com/amtoine/nu-git-manager│ssh://github.com/amtoine/nu-git-manager
# ─┴──────┴─────────────────────────────────────────┴───────────────────────────────────────
export def "gm repo remote list" []: nothing -> table<remote: string, fetch: string, push: string> {
# FIXME: use the helper `list-remotes` command from ../nu-git-manager/git/repo.nu:29
^git remote --verbose
Expand Down

0 comments on commit a3ca2a1

Please sign in to comment.