File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
tests/integration_tests/flow/scenarios Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ // Detached HEAD workflow scenario integration tests
2+
3+ use zerv:: cli:: flow:: test_utils:: expect_branch_hash;
4+ use zerv:: test_utils:: should_run_docker_tests;
5+
6+ use crate :: flow:: scenarios:: FlowIntegrationTestScenario ;
7+
8+ /// Test detached HEAD flow - when there is no branch (detached HEAD state)
9+ #[ test]
10+ fn test_detached_head_flow ( ) {
11+ if !should_run_docker_tests ( ) {
12+ return ;
13+ }
14+
15+ // Create repo with history
16+ let scenario = FlowIntegrationTestScenario :: new ( )
17+ . expect ( "Failed to create test scenario" )
18+ . create_tag ( "v1.0.0" )
19+ . commit ( ) // Commit after v1.0.0
20+ . commit ( ) ; // Another commit
21+
22+ // Get the commit hash for v1.0.0
23+ let v1_hash = scenario
24+ . get_head_commit ( )
25+ . expect ( "Failed to get HEAD commit" ) ;
26+
27+ // Checkout to v1.0.0 commit (this creates detached HEAD state)
28+ let scenario = scenario. commit ( ) . create_tag ( "v1.1.0" ) ;
29+
30+ let scenario = scenario. checkout ( & v1_hash) ;
31+
32+ let no_branch_hash = expect_branch_hash ( "" , 5 , "34769" ) ;
33+ // Now we're in detached HEAD state - verify zerv handles it
34+ let scenario = scenario. expect_version (
35+ & format ! ( "1.0.1-alpha.{}.post.2+2.g{{hex:7}}" , no_branch_hash) ,
36+ & format ! ( "1.0.1a{}.post2+2.g{{hex:7}}" , no_branch_hash) ,
37+ ) ;
38+
39+ let _ = scenario;
40+ }
Original file line number Diff line number Diff line change 11pub mod complex_release_branch;
2+ pub mod detached_head;
23pub mod gitflow;
34pub mod test_utils;
45pub mod trunk_based;
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ impl FlowIntegrationTestScenario {
106106 self . fixture . path ( ) . to_string_lossy ( ) . to_string ( )
107107 }
108108
109+ /// Get current HEAD commit hash
110+ pub fn get_head_commit ( & self ) -> Result < String , Box < dyn std:: error:: Error > > {
111+ self . fixture . get_head_commit ( )
112+ }
113+
109114 /// Copy the test repository to a temporary directory for debugging
110115 /// Creates a copy in .cache/tmp/<tmp_dir_name> that can be inspected manually
111116 /// If the directory already exists, it will be deleted first
You can’t perform that action at this time.
0 commit comments