File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
Cake.Common/Build/GitLabCI/Data Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ public GitLabCIInfoFixture(bool versionNineOrNewer = false)
65
65
Environment . GetEnvironmentVariable ( "CI_SERVER_VERSION" ) . Returns ( "8.9.0" ) ;
66
66
Environment . GetEnvironmentVariable ( "GITLAB_USER_ID" ) . Returns ( "42" ) ;
67
67
Environment . GetEnvironmentVariable ( "GITLAB_USER_EMAIL" ) . Returns ( "anthony@warwickcontrol.com" ) ;
68
+ Environment . GetEnvironmentVariable ( "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ) . Returns ( "source-branch" ) ;
69
+ Environment . GetEnvironmentVariable ( "CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ) . Returns ( "main" ) ;
68
70
}
69
71
70
72
public GitLabCIBuildInfo CreateBuildInfo ( )
Original file line number Diff line number Diff line change @@ -61,5 +61,37 @@ public void Should_Return_Correct_Value()
61
61
Assert . Equal ( 1 , result ) ;
62
62
}
63
63
}
64
+
65
+ public sealed class TheSourceBranchProperty
66
+ {
67
+ [ Fact ]
68
+ public void Should_Return_Correct_Value ( )
69
+ {
70
+ // Given
71
+ var info = new GitLabCIInfoFixture ( ) . CreatePullRequestInfo ( ) ;
72
+
73
+ // When
74
+ var result = info . SourceBranch ;
75
+
76
+ // Then
77
+ Assert . Equal ( "source-branch" , result ) ;
78
+ }
79
+ }
80
+
81
+ public sealed class TheTargetBranchProperty
82
+ {
83
+ [ Fact ]
84
+ public void Should_Return_Correct_Value ( )
85
+ {
86
+ // Given
87
+ var info = new GitLabCIInfoFixture ( ) . CreatePullRequestInfo ( ) ;
88
+
89
+ // When
90
+ var result = info . TargetBranch ;
91
+
92
+ // Then
93
+ Assert . Equal ( "main" , result ) ;
94
+ }
95
+ }
64
96
}
65
97
}
Original file line number Diff line number Diff line change @@ -43,5 +43,21 @@ public GitLabCIPullRequestInfo(ICakeEnvironment environment)
43
43
/// The pull request id.
44
44
/// </value>
45
45
public int IId => GetEnvironmentInteger ( "CI_MERGE_REQUEST_IID" ) ;
46
+
47
+ /// <summary>
48
+ /// Gets the source branch of the pull request.
49
+ /// </summary>
50
+ /// <value>
51
+ /// The source branch of the pull request.
52
+ /// </value>
53
+ public string SourceBranch => GetEnvironmentString ( "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ) ;
54
+
55
+ /// <summary>
56
+ /// Gets the target branch of the pull request.
57
+ /// </summary>
58
+ /// <value>
59
+ /// The target branch name of the pull request.
60
+ /// </value>
61
+ public string TargetBranch => GetEnvironmentString ( "CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ) ;
46
62
}
47
63
}
You can’t perform that action at this time.
0 commit comments