Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a default "fetch" strategy #195

Merged
merged 4 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-bisect.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo bisect` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L435))
# `gm repo bisect` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L440))
bisect a worktree by running a piece of code repeatedly

# Examples
Expand Down
3 changes: 2 additions & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-branch-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ fetch a remote branch locally, without pulling down the whole remote
## Parameters
- `remote` <`string@get-remotes`>: the branch to fetch
- `branch` <`string@get-branches`>: the remote to fetch the branch from
- `--strategy` <`string@get-strategies`> = `none`: the merge strategy to use
- `--strategy` <`string@get-strategies`>: the merge strategy to use, defaults to the `pull.rebase` Git
config option


## Signatures
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo branch interactive-delete` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L281))
# `gm repo branch interactive-delete` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L286))
remove a branch interactively


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-ls.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo ls` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L325))
# `gm repo ls` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L330))
get some information about a repo


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-query.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo query` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L375))
# `gm repo query` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L380))
queries the `.git/` directory as a database with `nu_plugin_git_query`

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-switch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo switch` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L301))
# `gm repo switch` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L306))
switch between branches interactively


Expand Down
7 changes: 6 additions & 1 deletion pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ export def "gm repo remote add" [name: string, remote: string, --ssh]: nothing -
export def "gm repo branch fetch" [
remote: string@get-remotes, # the branch to fetch
branch: string@get-branches, # the remote to fetch the branch from
--strategy: string@get-strategies = "none" # the merge strategy to use
--strategy: string@get-strategies # the merge strategy to use, defaults to the `pull.rebase` Git
# config option
]: nothing -> nothing {
let strategy = $strategy | default (
if (^git config pull.rebase) == "true" { "rebase" } else { "merge" }
)

^git fetch $remote $branch

if (^git branch --list | lines | str substring 2.. | where $it == $branch | is-empty) {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/nu-git-manager-sugar/tests/git.nu
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export def branch-fetch [] {

do {
cd $bar
gm repo branch fetch $"file://($foo)" foo
gm repo branch fetch $"file://($foo)" foo --strategy none

assert simple-git-tree-equal [
"(foo) c2",
Expand All @@ -159,7 +159,7 @@ export def branch-fetch [] {

do {
cd $bar
gm repo branch fetch $"file://($foo)" foo
gm repo branch fetch $"file://($foo)" foo --strategy none

assert simple-git-tree-equal [
"(foo) c4",
Expand All @@ -176,7 +176,7 @@ export def branch-fetch [] {

do {
cd $bar
gm repo branch fetch $"file://($foo)" foo
gm repo branch fetch $"file://($foo)" foo --strategy none

assert simple-git-tree-equal --extra-revs ["FETCH_HEAD"] [
"c6",
Expand Down
Loading