-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revset: allow
tags()
to take a pattern for an argument
This makes it more consistent with `bookmarks()`. Co-authored-by: Austin Seipp <[email protected]>
- Loading branch information
1 parent
ecd64aa
commit 499a194
Showing
5 changed files
with
155 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,3 +117,92 @@ fn test_tag_list() { | |
added_targets: commit2 | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_tag_patterns() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
let repo_path = test_env.env_root().join("repo"); | ||
let git_repo = { | ||
let mut git_repo_path = repo_path.clone(); | ||
git_repo_path.extend([".jj", "repo", "store", "git"]); | ||
git2::Repository::open(git_repo_path).unwrap() | ||
}; | ||
|
||
let copy_ref = |src_name: &str, dest_name: &str| { | ||
let src = git_repo.find_reference(src_name).unwrap(); | ||
let oid = src.target().unwrap(); | ||
git_repo.reference(dest_name, oid, true, "").unwrap(); | ||
}; | ||
|
||
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit1"]); | ||
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark1"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit2"]); | ||
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark2"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit3"]); | ||
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark3"]); | ||
test_env.jj_cmd_ok(&repo_path, &["git", "export"]); | ||
|
||
copy_ref("refs/heads/bookmark1", "refs/tags/test_tag"); | ||
copy_ref("refs/heads/bookmark2", "refs/tags/test_tag2"); | ||
copy_ref("refs/heads/bookmark3", "refs/tags/test_tag3"); | ||
copy_ref("refs/heads/bookmark1", "refs/tags/conflicted_tag"); | ||
test_env.jj_cmd_ok(&repo_path, &["git", "import"]); | ||
copy_ref("refs/heads/bookmark2", "refs/tags/conflicted_tag"); | ||
test_env.jj_cmd_ok(&repo_path, &["git", "import"]); | ||
copy_ref("refs/heads/bookmark3", "refs/tags/conflicted_tag"); | ||
test_env.jj_cmd_ok(&repo_path, &["git", "import", "--at-op=@-"]); | ||
test_env.jj_cmd_ok(&repo_path, &["status"]); // resolve concurrent ops | ||
|
||
insta::assert_snapshot!( | ||
test_env.jj_cmd_success(&repo_path, &["log", "-r", "tags()"]), | ||
@r###" | ||
◆ royxmykx [email protected] 2001-02-03 08:05:12 bookmark3 conflicted_tag?? test_tag3 68d950ce | ||
│ (empty) commit3 | ||
~ | ||
◆ zsuskuln [email protected] 2001-02-03 08:05:10 bookmark2 conflicted_tag?? test_tag2 3db783e0 | ||
│ (empty) commit2 | ||
~ | ||
◆ rlvkpnrz [email protected] 2001-02-03 08:05:08 bookmark1 test_tag caf975d0 | ||
│ (empty) commit1 | ||
~ | ||
"###); | ||
|
||
insta::assert_snapshot!( | ||
test_env.jj_cmd_success(&repo_path, &["log", "-r", "tags(test_tag)"]), | ||
@r###" | ||
◆ royxmykx [email protected] 2001-02-03 08:05:12 bookmark3 conflicted_tag?? test_tag3 68d950ce | ||
│ (empty) commit3 | ||
~ | ||
◆ zsuskuln [email protected] 2001-02-03 08:05:10 bookmark2 conflicted_tag?? test_tag2 3db783e0 | ||
│ (empty) commit2 | ||
~ | ||
◆ rlvkpnrz [email protected] 2001-02-03 08:05:08 bookmark1 test_tag caf975d0 | ||
│ (empty) commit1 | ||
~ | ||
"###); | ||
|
||
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "tags("]); | ||
insta::assert_snapshot!(stderr, | ||
@r###" | ||
Error: Failed to parse revset: Syntax error | ||
Caused by: --> 1:6 | ||
| | ||
1 | tags( | ||
| ^--- | ||
| | ||
= expected <identifier> or <expression> | ||
"###); | ||
|
||
insta::assert_snapshot!( | ||
test_env.jj_cmd_success(&repo_path, &["log", "-r", "tags(exact:test_tag)"]), | ||
@r" | ||
◆ rlvkpnrz [email protected] 2001-02-03 08:05:08 bookmark1 test_tag caf975d0 | ||
│ (empty) commit1 | ||
~ | ||
"); | ||
} |
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