-
Notifications
You must be signed in to change notification settings - Fork 160
feat: add interactive git restore selector #537
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
Open
sandr01d
wants to merge
1
commit into
wfxr:main
Choose a base branch
from
sandr01d:restore
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| function set_up_before_script() { | ||
| source bin/git-forgit | ||
|
|
||
| # Ignore global git config files | ||
| export GIT_CONFIG_SYSTEM=/dev/null | ||
| export GIT_CONFIG_GLOBAL=/dev/null | ||
|
|
||
| # Create a temporary git repository for testing | ||
| cd "$(bashunit::temp_dir)" || return 1 | ||
| git init -q | ||
| git config user.email "test@example.com" | ||
| git config user.name "Test User" | ||
|
|
||
| touch untracked.txt modified.txt staged.txt | ||
| git add modified.txt | ||
| git commit -q -m "modified" | ||
| echo modified >>modified.txt | ||
| git add staged.txt | ||
| } | ||
|
|
||
| function test_list_staged_files_only_lists_staged() { | ||
| output=$(_forgit_list_staged_files) | ||
|
|
||
| assert_same "$output" "staged.txt" | ||
| } | ||
|
|
||
| function test_list_staged_files_shows_relative_paths() { | ||
| mkdir subdirectory | ||
| cd subdirectory || return 1 | ||
|
|
||
| output=$(_forgit_list_staged_files) | ||
| assert_same "$output" "../staged.txt" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| function set_up_before_script() { | ||
| source bin/git-forgit | ||
|
|
||
| # Ignore global git config files | ||
| export GIT_CONFIG_SYSTEM=/dev/null | ||
| export GIT_CONFIG_GLOBAL=/dev/null | ||
|
|
||
| # Create a temporary git repository for testing | ||
| cd "$(bashunit::temp_dir)" || return 1 | ||
| git init -q | ||
| git config user.email "test@example.com" | ||
| git config user.name "Test User" | ||
| } | ||
|
|
||
| function test_restore_shows_message_when_no_modified_files() { | ||
| output=$(_forgit_restore 2>&1) | ||
| assert_general_error | ||
| assert_same "Nothing to restore." "$output" | ||
| } | ||
|
|
||
| function test_parse_restore_args() { | ||
| IFS=$'\t' read -r staged worktree preview_arg < <(_forgit_parse_restore_flags --staged) | ||
|
|
||
| assert_same "$staged" true | ||
| assert_same "$worktree" false | ||
| assert_same "$preview_arg" --staged | ||
|
|
||
| IFS=$'\t' read -r staged worktree preview_arg < <(_forgit_parse_restore_flags --worktree) | ||
| assert_same "$staged" false | ||
| assert_same "$worktree" true | ||
| assert_same "$preview_arg" '' | ||
|
|
||
| IFS=$'\t' read -r staged worktree preview_arg < <(_forgit_parse_restore_flags --worktree --staged) | ||
| assert_same "$staged" true | ||
| assert_same "$worktree" true | ||
| assert_same "$preview_arg" HEAD | ||
|
|
||
| IFS=$'\t' read -r staged worktree preview_arg < <(_forgit_parse_restore_flags -W -S) | ||
| assert_same "$staged" true | ||
| assert_same "$worktree" true | ||
| assert_same "$preview_arg" HEAD | ||
|
|
||
| # other flags do not change the outcome | ||
| IFS=$'\t' read -r staged worktree preview_arg < <(_forgit_parse_restore_flags -W -S -U --unknown-flag) | ||
| assert_same "$staged" true | ||
| assert_same "$worktree" true | ||
| assert_same "$preview_arg" HEAD | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.