77import org .scm4j .releaser .branch .ReleaseBranchCurrent ;
88import org .scm4j .releaser .branch .ReleaseBranchFactory ;
99import org .scm4j .releaser .branch .ReleaseBranchPatch ;
10- import org .scm4j .releaser .conf .Component ;
11- import org .scm4j .releaser .conf .DelayedTagsFile ;
12- import org .scm4j .releaser .conf .VCSRepository ;
13- import org .scm4j .releaser .conf .VCSRepositoryFactory ;
10+ import org .scm4j .releaser .conf .*;
1411import org .scm4j .releaser .exceptions .ENoReleaseBranchForPatch ;
1512import org .scm4j .releaser .exceptions .ENoReleases ;
1613import org .scm4j .releaser .exceptions .EReleaseMDepsNotLocked ;
@@ -74,7 +71,7 @@ public ExtendedStatus getAndCacheStatus(Component comp, CachedStatuses cache, IP
7471 }
7572
7673 DelayedTagsFile dtf = new DelayedTagsFile ();
77- Boolean hasDelayedTag = dtf .getRevisitonByUrl (repo .getUrl ()) != null ;
74+ Boolean hasDelayedTag = dtf .getDelayedTagByUrl (repo .getUrl ()) != null ;
7875
7976 ExtendedStatus res = patch ?
8077 getPatchStatus (comp , cache , progress , repo , hasDelayedTag ) :
@@ -151,44 +148,22 @@ private ExtendedStatus getPatchStatus(Component comp, CachedStatuses cache, IPro
151148 subComponents .put (mdep , subComponentsLocal .get (mdep ));
152149 }
153150
154- String errorDesc = null ;
155- if (hasMDepsInERRORStatus (rb .getMDeps (), cache )) {
156- buildStatus = BuildStatus .ERROR ;
157- errorDesc = "has components in ERROR status" ;
151+ if (hasMDepsNotInDONEStatus (rb .getMDeps (), cache )) {
152+ buildStatus = BuildStatus .BUILD_MDEPS ;
153+ } else if (!areMDepsPatchesActual (rb .getMDeps (), cache )) {
154+ buildStatus = BuildStatus .ACTUALIZE_PATCHES ;
155+ } else if (reportDuration (() -> noValueableCommitsAfterLastTag (repo , rb ), "is release branch modified check" , comp , progress )) {
156+ buildStatus = BuildStatus .DONE ;
158157 } else {
159- Version lastTagVersion = reportDuration (() -> getLastTagVersion (repo , rb ), "last tag determination" , comp , progress );
160- Version expectedHeadVer = lastTagVersion != null ? hasDelayedTag ? lastTagVersion : lastTagVersion .toNextPatch () : null ;
161- Version actualVersion = rb .getVersion ();
162- if (lastTagVersion != null && !actualVersion .equals (expectedHeadVer )) {
163- buildStatus = BuildStatus .ERROR ;
164- errorDesc = String .format ("last tag %s does not correspond to %s head version. Expected version: %s, actual: %s" , lastTagVersion + (hasDelayedTag ? " (delayed)" : "" ), rb .getName (),
165- expectedHeadVer + (hasDelayedTag ? " (considering delayed tag)" : "" ), actualVersion );
166- } else if (hasMDepsNotInDONEStatus (rb .getMDeps (), cache )) {
167- buildStatus = BuildStatus .BUILD_MDEPS ;
168- } else if (!areMDepsPatchesActual (rb .getMDeps (), cache )) {
169- buildStatus = BuildStatus .ACTUALIZE_PATCHES ;
170- } else if (reportDuration (() -> noValueableCommitsAfterLastTag (repo , rb ), "is release branch modified check" , comp , progress )) {
171- buildStatus = BuildStatus .DONE ;
172- } else {
173- buildStatus = BuildStatus .BUILD ;
174- }
158+ buildStatus = BuildStatus .BUILD ;
175159 }
176-
160+
177161 Version nextVersion = rb .getVersion ();
178162 if (hasDelayedTag ) {
179163 nextVersion = nextVersion .toNextPatch ();
180164 }
181165
182- return new ExtendedStatus (nextVersion , buildStatus , subComponents , comp , repo , errorDesc );
183- }
184-
185- private boolean hasMDepsInERRORStatus (List <Component > mDeps , CachedStatuses cache ) {
186- for (Component mDep : mDeps ) {
187- if (cache .get (repoFactory .getUrl (mDep )).getStatus () == BuildStatus .ERROR ) {
188- return true ;
189- }
190- }
191- return false ;
166+ return new ExtendedStatus (nextVersion , buildStatus , subComponents , comp , repo );
192167 }
193168
194169 private boolean hasMDepsNotInDONEStatus (List <Component > mDeps , CachedStatuses cache ) {
@@ -200,32 +175,12 @@ private boolean hasMDepsNotInDONEStatus(List<Component> mDeps, CachedStatuses ca
200175 return false ;
201176 }
202177
203- private Version getLastTagVersion (VCSRepository repo , ReleaseBranchPatch rb ) {
204- IVCS vcs = repo .getVCS ();
205- DelayedTagsFile dtf = new DelayedTagsFile ();
206- String delayedTagRevision = dtf .getRevisitonByUrl (repo .getUrl ());
207- Version res = walkOnCommitTags (repo , rb , (commit ) -> {
208- if (commit .getRevision ().equals (delayedTagRevision )) {
209- return new Version (vcs .getFileContent (rb .getName (), Utils .VER_FILE_NAME , delayedTagRevision ));
210- }
211- List <VCSTag > tags = vcs .getTagsOnRevision (commit .getRevision ());
212- for (VCSTag tag : tags ) {
213- Version ver = new Version (tag .getTagName ());
214- if (ver .isSemantic ()) {
215- return ver ;
216- }
217- }
218- return null ;
219- });
220- return res ;
221- }
222-
223178 private boolean noValueableCommitsAfterLastTag (VCSRepository repo , ReleaseBranchPatch rb ) {
224179 IVCS vcs = repo .getVCS ();
225180 DelayedTagsFile dtf = new DelayedTagsFile ();
226- String delayedTagRevision = dtf .getRevisitonByUrl (repo .getUrl ());
227- Boolean res = walkOnCommitTags (repo , rb , (commit ) -> {
228- if (commit .getRevision ().equals (delayedTagRevision )) {
181+ DelayedTag delayedTag = dtf .getDelayedTagByUrl (repo .getUrl ());
182+ Boolean res = walkOnCommits (repo , rb , (commit ) -> {
183+ if (delayedTag != null && commit .getRevision ().equals (delayedTag . getRevision () )) {
229184 return true ;
230185 }
231186 List <VCSTag > tags = vcs .getTagsOnRevision (commit .getRevision ());
@@ -240,7 +195,7 @@ private boolean noValueableCommitsAfterLastTag(VCSRepository repo, ReleaseBranch
240195 return res == null ? true : res ;
241196 }
242197
243- private <T > T walkOnCommitTags (VCSRepository repo , ReleaseBranchPatch rb , Function <VCSCommit , T > func ) {
198+ private <T > T walkOnCommits (VCSRepository repo , ReleaseBranchPatch rb , Function <VCSCommit , T > func ) {
244199 IVCS vcs = repo .getVCS ();
245200 String startingFromRevision = null ;
246201
@@ -265,7 +220,7 @@ private boolean areMDepsPatchesActual(List<Component> mDeps, CachedStatuses cach
265220 Version nextMDepVersion = cache .get (url ).getNextVersion ();
266221 if (!nextMDepVersion .equals (mDep .getVersion ().toNextPatch ())) {
267222 DelayedTagsFile mdf = new DelayedTagsFile ();
268- if (!(nextMDepVersion .getPatch ().equals (ZERO_PATCH ) && mdf .getRevisitonByUrl (url ) != null )) {
223+ if (!(nextMDepVersion .getPatch ().equals (ZERO_PATCH ) && mdf .getDelayedTagByUrl (url ) != null )) {
269224 return false ;
270225 }
271226 }
0 commit comments