-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
6 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use command_error::CommandExt; | ||
use expect_test::expect; | ||
use pretty_assertions::assert_eq; | ||
use test_harness::GitProle; | ||
|
||
#[test] | ||
fn add_branch_start_point_existing_local() { | ||
let prole = GitProle::new().unwrap(); | ||
prole.setup_worktree_repo("my-repo").unwrap(); | ||
|
||
// Create a new branch and commit to base our new worktree off of. | ||
prole | ||
.sh(" | ||
cd my-repo/main || exit | ||
git switch -c doggy | ||
echo 'cutie puppy' > README.md | ||
git commit -am 'Cooler README' | ||
git switch main | ||
") | ||
.unwrap(); | ||
|
||
prole | ||
.cd_cmd("my-repo/main") | ||
.args(["add", "-b", "softy", "puppy", "doggy"]) | ||
.status_checked() | ||
.unwrap(); | ||
|
||
prole.assert_contents(&[( | ||
"my-repo/puppy/README.md", | ||
expect![[r#" | ||
cutie puppy | ||
"#]], | ||
)]); | ||
|
||
assert_eq!(prole.current_branch_in("my-repo/puppy").unwrap(), "softy"); | ||
|
||
assert_eq!( | ||
prole | ||
.upstream_for_branch_in("my-repo/puppy", "softy") | ||
.unwrap(), | ||
"doggy" | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use command_error::CommandExt; | ||
use expect_test::expect; | ||
use pretty_assertions::assert_eq; | ||
use test_harness::GitProle; | ||
|
||
#[test] | ||
fn add_branch_start_point_existing_remote() { | ||
let prole = GitProle::new().unwrap(); | ||
prole.setup_repo("my-remote/my-repo").unwrap(); | ||
// Set up a `puppy` branch in the remote. | ||
prole | ||
.sh(" | ||
cd my-remote/my-repo || exit | ||
git switch -c puppy | ||
echo 'softy pup' > README.md | ||
git commit -am 'cooler readme' | ||
git switch main | ||
") | ||
.unwrap(); | ||
|
||
prole | ||
.cmd() | ||
.args(["clone", "my-remote/my-repo"]) | ||
.status_checked() | ||
.unwrap(); | ||
|
||
prole | ||
.cd_cmd("my-repo/main") | ||
.args(["add", "-b", "softie", "doggy", "puppy"]) | ||
.status_checked() | ||
.unwrap(); | ||
|
||
// We get a checkout for the remote-tracking branch! | ||
prole.assert_contents(&[( | ||
"my-repo/doggy/README.md", | ||
expect![[r#" | ||
softy pup | ||
"#]], | ||
)]); | ||
|
||
assert_eq!(prole.current_branch_in("my-repo/doggy").unwrap(), "softie"); | ||
|
||
// We're tracking the remote branch we expect. | ||
assert_eq!( | ||
prole | ||
.upstream_for_branch_in("my-repo/doggy", "softie") | ||
.unwrap(), | ||
"origin/puppy" | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use command_error::CommandExt; | ||
use expect_test::expect; | ||
use pretty_assertions::assert_eq; | ||
use test_harness::GitProle; | ||
|
||
#[test] | ||
fn add_branch_start_point_new_local() { | ||
let prole = GitProle::new().unwrap(); | ||
prole.setup_worktree_repo("my-repo").unwrap(); | ||
|
||
prole | ||
.sh(" | ||
cd my-repo/main || exit | ||
git switch -c puppy | ||
echo 'soft cutie' > README.md | ||
git commit -am 'Cooler readme' | ||
") | ||
.unwrap(); | ||
|
||
prole | ||
.cd_cmd("my-repo/main") | ||
.args(["add", "-c", "softy", "doggy", "@"]) | ||
.status_checked() | ||
.unwrap(); | ||
|
||
prole.assert_contents(&[( | ||
"my-repo/doggy/README.md", | ||
expect![[r#" | ||
soft cutie | ||
"#]], | ||
)]); | ||
|
||
assert_eq!(prole.current_branch_in("my-repo/doggy").unwrap(), "softy"); | ||
} |