1010import org .scm4j .releaser .branch .ReleaseBranchCurrent ;
1111import org .scm4j .releaser .branch .ReleaseBranchFactory ;
1212import org .scm4j .releaser .branch .ReleaseBranchPatch ;
13+ import org .scm4j .releaser .cli .CLICommand ;
14+ import org .scm4j .releaser .cli .Option ;
1315import org .scm4j .releaser .conf .*;
1416import org .scm4j .releaser .exceptions .EDelayingDelayed ;
1517import org .scm4j .releaser .exceptions .ENoDelayedTags ;
@@ -37,29 +39,43 @@ public void setUpTearDown() {
3739 public void testDelayedTagOnPatch () throws Exception {
3840 forkAndBuild (compUnTill );
3941
40- // add feature to unTillDb release/2.59
41- Component compUnTillDbVersioned = compUnTillDb .clone (env .getUnTillDbVer ());
42- ReleaseBranchPatch rb = ReleaseBranchFactory .getReleaseBranchPatch (compUnTillDbVersioned .getVersion (), repoUnTillDb );
43- env .generateFeatureCommit (env .getUnTillDbVCS (), rb .getName (), "patch feature merged" );
42+ // add feature to unTill
43+ Component compUnTillVersioned = compUnTill .clone (env .getUnTillVer (). toReleaseZeroPatch ());
44+ ReleaseBranchPatch rb = ReleaseBranchFactory .getReleaseBranchPatch (compUnTillVersioned .getVersion (), repoUnTillDb );
45+ env .generateFeatureCommit (env .getUnTillVCS (), rb .getName (), "patch feature merged" );
4446
4547 // build all patches, delayed tag
46- Component compUnTillVersioned = compUnTill .clone (env .getUnTillVer ().toReleaseZeroPatch ());
4748 IAction action = execAndGetActionBuildDelayedTag (compUnTillVersioned );
48- assertActionDoesBuildAllDelayedTag (action );
49+ assertActionDoesBuildDelayedTag (action , compUnTillVersioned );
4950
50- // check no new tags
51- Assert .assertEquals (2 , env .getUblVCS ().getTags ().size ());
52- Assert .assertEquals (2 , env .getUnTillDbVCS ().getTags ().size ());
51+ // check root component patch tag is delayed
52+ Assert .assertEquals (1 , env .getUblVCS ().getTags ().size ());
53+ Assert .assertEquals (1 , env .getUnTillDbVCS ().getTags ().size ());
5354 Assert .assertEquals (1 , env .getUnTillVCS ().getTags ().size ());
54-
55- // check Delayed Tags file
56- assertNull (dtf .getDelayedTagByUrl (repoUnTillDb .getUrl ()));
57- assertNotNull (dtf .getDelayedTagByUrl (repoUnTill .getUrl ()));
58- assertNull (dtf .getDelayedTagByUrl (repoUBL .getUrl ()));
5955
60- // check Delayed Tags are used
56+ // check component with delayed tag is considered as tagged (DONE) on build
6157 action = execAndGetActionBuild (compUnTillVersioned );
6258 assertActionDoesNothing (action );
59+
60+ // check no exceptions on status command with --delayed-tag option
61+ execAndGetNode (null , CLICommand .STATUS .getCmdLineStr (),
62+ compUnTillVersioned .getCoords ().toString (), Option .DELAYED_TAG .getCmdLineStr ());
63+
64+ // check Delayed Tags file
65+ DelayedTag delayedTag = dtf .getDelayedTagByUrl (repoUnTill .getUrl ());
66+ assertEquals (env .getUnTillVer ().toReleaseZeroPatch ().toNextPatch (), delayedTag .getVersion ());
67+ ReleaseBranchPatch patchRB = ReleaseBranchFactory .getReleaseBranchPatch (compUnTillVersioned .getVersion (), repoUnTill );
68+ VCSCommit commitToTag = env .getUnTillVCS ().getHeadCommit (patchRB .getName ());
69+ assertEquals (delayedTag .getRevision (), commitToTag .getRevision ());
70+
71+ // create tag which was delayed
72+ action = execAndGetActionTag (compUnTill , null );
73+ assertActionDoesTag (action , compUnTill );
74+
75+ // check tags
76+ assertTrue (isPreHeadCommitTaggedWithVersion (compUBL ));
77+ assertTrue (isPreHeadCommitTaggedWithVersion (compUnTillDb ));
78+ assertTrue (isPreHeadCommitTaggedWithVersion (compUnTill ));
6379 }
6480
6581 @ Test
@@ -77,11 +93,22 @@ public void testDelayedTagOnMinor() throws Exception {
7793 action = execAndGetActionBuild (compUnTill );
7894 assertActionDoesNothing (action );
7995
96+ // expect no exceptions on status command with --delayed-tag option
97+ execAndGetNode (null , CLICommand .STATUS .getCmdLineStr (),
98+ compUnTill .getCoords ().toString (), Option .DELAYED_TAG .getCmdLineStr ());
99+
80100 // check Delayed Tags file
81101 assertNull (dtf .getDelayedTagByUrl (repoUnTillDb .getUrl ()));
82102 assertNotNull (dtf .getDelayedTagByUrl (repoUnTill .getUrl ()));
83103 assertNull (dtf .getDelayedTagByUrl (repoUBL .getUrl ()));
84104
105+ // check delayed tag
106+ DelayedTag delayedTag = dtf .getDelayedTagByUrl (repoUnTill .getUrl ());
107+ assertEquals (env .getUnTillVer ().toReleaseZeroPatch (), delayedTag .getVersion ());
108+ ReleaseBranchCurrent crb = ReleaseBranchFactory .getCRB (repoUnTill );
109+ VCSCommit commitToTag = env .getUnTillVCS ().getHeadCommit (crb .getName ());
110+ assertEquals (delayedTag .getRevision (), commitToTag .getRevision ());
111+
85112 // create tag which was delayed
86113 action = execAndGetActionTag (compUnTill , null );
87114 assertActionDoesTag (action , compUnTill );
@@ -221,15 +248,19 @@ public void testMDepTagDelayed() {
221248
222249 @ Test
223250 public void testDelayingDelayed () {
224- fork (compUnTillDb );
225- IAction action = execAndGetActionBuildDelayedTag (compUnTillDb );
226- assertActionDoesBuildDelayedTag (action , compUnTillDb );
251+ forkAndBuild (compUnTillDb );
227252
228253 ReleaseBranchCurrent crb = ReleaseBranchFactory .getCRB (repoUnTillDb );
229254 env .generateFeatureCommit (env .getUnTillDbVCS (), crb .getName (), "feature merged" );
230255
256+ Component compUnTillDbPatch = compUnTillDb .clone (env .getUnTillDbVer ().toReleaseZeroPatch ());
257+
258+ IAction action = execAndGetActionBuildDelayedTag (compUnTillDbPatch );
259+ assertActionDoesBuildDelayedTag (action , compUnTillDbPatch );
260+
261+ env .generateFeatureCommit (env .getUnTillDbVCS (), crb .getName (), "feature merged" );
262+
231263 // try to build next untillDb patch with delayed tag
232- Component compUnTillDbPatch = new Component (UNTILLDB + ":" + env .getUnTillDbVer ().toRelease ());
233264 try {
234265 execAndGetActionBuildDelayedTag (compUnTillDbPatch );
235266 fail ();
@@ -297,5 +328,3 @@ private boolean isPreHeadCommitTaggedWithVersion(Component comp) {
297328 return false ;
298329 }
299330}
300-
301-
0 commit comments