-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] Add
--patch
option to mr show
Fixes #277 which requests functionality that provides the patches for an MR in 'git show' format. This is useful for users that want to quickly look at a patchset without checking out a branch. The original patch provided by Eric required users to provide the target remote, even if the target remote was "origin". The additional code provided by Prarit uses the fetch remote name in 'git remote -v' by default unless the user specifies a specific remote. Original patch from Eric, with modifications to automatically find the target remote, and the test from Prarit. Add '--patch' option to 'mr show' that displays the patches for a merge request in 'git show' format. Co-Developed-by: Eric Engestrom <[email protected]> Signed-off-by: Prarit Bhargava <[email protected]>
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -45,3 +45,31 @@ WebURL: https://gitlab.com/zaquestion/test/-/merge_requests/1 | |
require.Contains(t, string(b), `commented at`) | ||
require.Contains(t, string(b), `updated comment at`) | ||
} | ||
|
||
func Test_mrShow_patch(t *testing.T) { | ||
t.Parallel() | ||
repo := copyTestRepo(t) | ||
cmd := exec.Command(labBinaryPath, "mr", "show", "origin", "1", "--patch") | ||
cmd.Dir = repo | ||
|
||
b, err := cmd.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
out := string(b) | ||
out = stripansi.Strip(out) | ||
// The index line below has been stripped as it is dependent on | ||
// the git version and pretty defaults. | ||
require.Contains(t, out, `commit 54fd49a2ac60aeeef5ddc75efecd49f85f7ba9b0 | ||
Author: Zaq? Wiedmann <[email protected]> | ||
Date: Tue Sep 19 03:55:16 2017 +0000 | ||
Test file for MR test | ||
diff --git a/mrtest b/mrtest | ||
new file mode 100644 | ||
`) | ||
|
||
} |
This file contains 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