Skip to content

Commit b010665

Browse files
committed
Merge branch 'master' into release/2
# Conflicts: # README.md # run.groovy # version
2 parents b5e772c + 043489a commit b010665

File tree

73 files changed

+1492
-1391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1492
-1391
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ cache:
1010
- $HOME/.gradle/wrapper/
1111
after_success:
1212
- ./gradlew jacocoTestReport coveralls
13-
#after_failure:
14-
# - cat build/test-results/test/*.xml
13+
after_failure:
14+
- cat build/test-results/test/*.xml

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[![Release](https://jitpack.io/v/scm4j/scm4j-wf.svg)](https://jitpack.io/#scm4j/scm4j-wf)
2-
[![Build Status](https://travis-ci.org/scm4j/scm4j-wf.svg?branch=release/2)](https://travis-ci.org/scm4j/scm4j-wf)
3-
[![Coverage Status](https://coveralls.io/repos/github/scm4j/scm4j-wf/badge.svg?branch=release/2)](https://coveralls.io/github/scm4j/scm4j-wf?branch=release/2)
1+
[![Release](https://jitpack.io/v/scm4j/scm4j-releaser.svg)](https://jitpack.io/#scm4j/scm4j-releaser)
2+
[![Build Status](https://travis-ci.org/scm4j/scm4j-releaser.svg?branch=master)](https://travis-ci.org/scm4j/scm4j-releaser)
3+
[![Coverage Status](https://coveralls.io/repos/github/scm4j/scm4j-releaser/badge.svg?branch=master)](https://coveralls.io/github/scm4j/scm4j-releaser?branch=master)
44

55
# Status
66

@@ -29,7 +29,7 @@ For version definitions ref. [semantic Versioning 2.0.0](http://semver.org/).
2929

3030
# Installation
3131

32-
Install groovy, download [run.grovy](https://raw.githubusercontent.com/scm4j/scm4j-wf/master/run.groovy) and execute `groovy run.groovy`, it will list available commands
32+
Install groovy, download [run.grovy](https://raw.githubusercontent.com/scm4j/scm4j-releaser/release/2/run.groovy) and execute `groovy run.groovy`, it will list available commands
3333

3434
# Data Structure
3535

@@ -43,4 +43,4 @@ Install groovy, download [run.grovy](https://raw.githubusercontent.com/scm4j/scm
4343

4444
# See also
4545

46-
[Historical version](https://github.com/scm4j/scm4j-wf/blob/d540cb00674d485846117dbd68df19bdad306e56/README.md)
46+
[Historical version](https://github.com/scm4j/scm4j-releaser/blob/d540cb00674d485846117dbd68df19bdad306e56/README.md)

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ repositories {
3131
}
3232

3333
test {
34-
testLogging.showStandardStreams = true
3534
jvmArgs '-Xmx128m'
35+
testLogging {
36+
events "failed"
37+
exceptionFormat "full"
38+
}
3639
}
3740

3841
dependencies {
@@ -45,8 +48,6 @@ dependencies {
4548

4649
testCompile 'junit:junit:4.12'
4750
testCompile 'org.mockito:mockito-all:1.9.5'
48-
testCompile 'org.powermock:powermock-mockito-release-full:1.6.3'
49-
testCompile 'org.powermock:powermock-api-mockito:1.6.3'
5051
testCompile 'nl.jqno.equalsverifier:equalsverifier:2.3'
5152
testCompile 'org.hamcrest:hamcrest-all:1.3'
5253

docs/branches-statuses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All statuses are calculated by `BranchesStatuses` class
1616
- `MDEPS_FROZEN`
1717
- All mdeps (if any) have fixed version
1818
- `MDEPS_ACTUAL`
19-
- For every mdeps entry tag which corresponds to mdeps.component.version exists and points to the component-repo.branches.version.commits.head-1
19+
- For every mdeps entry tag which corresponds to mdeps.component.version exists and points to the component-repo.branches.version.commits.head-1. Or no mdeps at all.
2020
- `ACTUAL`
2121
- `MDEPS_ACTUAL` (or no mdeps) and tag which corresponds to version.minor.patch-1 exists and points to head-1 (no commits after last patch but `#scm-ver`)
2222

run.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
@GrabResolver(name='jitpack', root='https://jitpack.io')
2-
@Grab('com.github.scm4j:scm4j-wf:2.0')
2+
@Grab('com.github.scm4j:scm4j-releaser:master-SNAPSHOT')
33

4-
import org.scm4j.wf.cli.CLI;
4+
import org.scm4j.releaser.cli.CLI;
5+
import org.scm4j.releaser.exceptions.EConfig;
56

67
class CLIRunner {
78
static void main(args) {
9+
try {
810
CLI.main(args);
11+
} catch (EConfig e) {
912
}
1013
}
14+
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'scm4j-wf'
1+
rootProject.name = 'scm4j-releaser'

src/main/java/org/scm4j/wf/LogTag.java renamed to src/main/java/org/scm4j/releaser/LogTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.scm4j.wf;
1+
package org.scm4j.releaser;
22

33
public class LogTag {
44
public static final String SCM_VER = "#scm-ver";

src/main/java/org/scm4j/wf/SCMWorkflow.java renamed to src/main/java/org/scm4j/releaser/SCMReleaser.java

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
package org.scm4j.wf;
1+
package org.scm4j.releaser;
22

3+
import org.scm4j.commons.Version;
4+
import org.scm4j.releaser.actions.ActionKind;
5+
import org.scm4j.releaser.actions.ActionNone;
6+
import org.scm4j.releaser.actions.IAction;
7+
import org.scm4j.releaser.branch.DevelopBranch;
8+
import org.scm4j.releaser.branch.DevelopBranchStatus;
9+
import org.scm4j.releaser.branch.ReleaseBranch;
10+
import org.scm4j.releaser.branch.ReleaseBranchStatus;
11+
import org.scm4j.releaser.conf.*;
12+
import org.scm4j.releaser.exceptions.EComponentConfig;
13+
import org.scm4j.releaser.scmactions.ReleaseReason;
14+
import org.scm4j.releaser.scmactions.SCMActionBuild;
15+
import org.scm4j.releaser.scmactions.SCMActionFork;
16+
import org.scm4j.releaser.scmactions.SCMActionTagRelease;
317
import org.scm4j.vcs.api.IVCS;
418
import org.scm4j.vcs.api.VCSTag;
5-
import org.scm4j.wf.actions.ActionKind;
6-
import org.scm4j.wf.actions.ActionNone;
7-
import org.scm4j.wf.actions.IAction;
8-
import org.scm4j.wf.branch.DevelopBranch;
9-
import org.scm4j.wf.branch.DevelopBranchStatus;
10-
import org.scm4j.wf.branch.ReleaseBranch;
11-
import org.scm4j.wf.branch.ReleaseBranchStatus;
12-
import org.scm4j.wf.conf.*;
13-
import org.scm4j.wf.exceptions.EComponentConfig;
14-
import org.scm4j.wf.scmactions.ReleaseReason;
15-
import org.scm4j.wf.scmactions.SCMActionBuild;
16-
import org.scm4j.wf.scmactions.SCMActionFork;
17-
import org.scm4j.wf.scmactions.SCMActionTagRelease;
1819

1920
import java.io.File;
2021
import java.util.ArrayList;
2122
import java.util.List;
2223
import java.util.ListIterator;
2324

24-
public class SCMWorkflow {
25+
public class SCMReleaser {
2526

2627
public static final String MDEPS_FILE_NAME = "mdeps";
2728
public static final String VER_FILE_NAME = "version";
@@ -30,11 +31,11 @@ public class SCMWorkflow {
3031

3132
private final List<Option> options;
3233

33-
public SCMWorkflow(List<Option> options) {
34+
public SCMReleaser(List<Option> options) {
3435
this.options = options;
3536
}
3637

37-
public SCMWorkflow() {
38+
public SCMReleaser() {
3839
this(new ArrayList<Option>());
3940
}
4041

@@ -49,15 +50,15 @@ public static List<Option> parseOptions(String[] args) {
4950
}
5051

5152
public static File getDelayedTagsFile() {
52-
return new File(SCMWorkflow.DELAYED_TAGS_FILE_NAME);
53+
return new File(SCMReleaser.DELAYED_TAGS_FILE_NAME);
5354
}
5455

5556
public IAction getProductionReleaseAction(String componentName) {
56-
return getProductionReleaseAction(new Component(componentName), ActionKind.AUTO);
57+
return getProductionReleaseAction(new Component(componentName, true), ActionKind.AUTO);
5758
}
5859

5960
public IAction getProductionReleaseAction(String componentCoords, ActionKind actionKind) {
60-
return getProductionReleaseAction(new Component(componentCoords), actionKind);
61+
return getProductionReleaseAction(new Component(componentCoords, true), actionKind);
6162
}
6263

6364
public IAction getProductionReleaseAction(Component comp) {
@@ -66,11 +67,16 @@ public IAction getProductionReleaseAction(Component comp) {
6667

6768
public IAction getProductionReleaseAction(Component comp, ActionKind actionKind) {
6869
List<IAction> childActions = new ArrayList<>();
69-
DevelopBranch db = new DevelopBranch(comp);
70-
List<Component> devMDeps = db.getMDeps();
70+
ReleaseBranch rb = new ReleaseBranch(comp);
71+
List<Component> mDeps;
72+
if (rb.exists()) {
73+
mDeps = rb.getMDeps();
74+
} else {
75+
mDeps = new DevelopBranch(comp).getMDeps();
76+
}
7177

72-
for (Component mDep : devMDeps) {
73-
childActions.add(getProductionReleaseAction(mDep, actionKind));
78+
for (Component mDep : mDeps) {
79+
childActions.add(getProductionReleaseAction(mDep, actionKind));
7480
}
7581

7682
return getProductionReleaseActionRoot(comp, childActions, actionKind);
@@ -86,44 +92,41 @@ public IAction getProductionReleaseActionRoot(Component comp, List<IAction> chil
8692
if (dbs == DevelopBranchStatus.IGNORED) {
8793
return new ActionNone(comp, childActions, "develop branch is IGNORED");
8894
}
89-
95+
9096
ReleaseBranch rb = new ReleaseBranch(comp);
9197
ReleaseBranchStatus rbs = rb.getStatus();
9298

9399
if (rbs == ReleaseBranchStatus.MISSING) {
94100
skipAllBuilds(childActions);
95101
if (actionKind == ActionKind.BUILD) {
96-
return new ActionNone(comp, childActions, "nothing to build ");
97-
}
98-
if (dbs == DevelopBranchStatus.MODIFIED) {
99-
return new SCMActionFork(comp, childActions, ReleaseReason.NEW_FEATURES, options);
100-
} else {
101-
return new SCMActionFork(comp, childActions, ReleaseReason.NEW_DEPENDENCIES, options);
102+
return new ActionNone(comp, childActions, "nothing to build. " + rb.getVersion() + " " + rb.getStatus());
102103
}
104+
105+
return new SCMActionFork(comp, childActions, ReleaseBranchStatus.MISSING, ReleaseBranchStatus.MDEPS_ACTUAL, options);
103106
}
104107

105108
if (rbs == ReleaseBranchStatus.BRANCHED) {
106109
// need to freeze mdeps
107110
skipAllBuilds(childActions);
108111
if (actionKind == ActionKind.BUILD) {
109-
return new ActionNone(comp, childActions, "nothing to build");
112+
return new ActionNone(comp, childActions, "nothing to build. " + rb.getVersion() + " " + rb.getStatus());
110113
}
111-
return new SCMActionFork(comp, childActions, ReleaseReason.NEW_FEATURES, options);
114+
return new SCMActionFork(comp, childActions, ReleaseBranchStatus.BRANCHED, ReleaseBranchStatus.MDEPS_ACTUAL, options);
112115
}
113116

114117
if (rbs == ReleaseBranchStatus.MDEPS_FROZEN) {
115118
if (needToActualizeMDeps(rb)) {
116119
// need to actualize
117120
skipAllBuilds(childActions);
118121
if (actionKind == ActionKind.BUILD) {
119-
return new ActionNone(comp, childActions, "nothing to build");
122+
return new ActionNone(comp, childActions, "nothing to build. " + rb.getVersion() + " " + rb.getStatus());
120123
}
121-
return new SCMActionFork(comp, childActions, ReleaseReason.ACTUALIZE_MDEPS, options);
124+
return new SCMActionFork(comp, childActions, ReleaseBranchStatus.MDEPS_FROZEN, ReleaseBranchStatus.MDEPS_ACTUAL, options);
122125
} else {
123126
// All necessary version will be build by Child Actions. Need to build
124127
skipAllForks(childActions);
125128
if (actionKind == ActionKind.FORK) {
126-
return new ActionNone(comp, childActions, "nothing to fork");
129+
return new ActionNone(comp, childActions, "nothing to fork. " + rb.getVersion() + " " + rb.getStatus());
127130
}
128131
return new SCMActionBuild(comp, childActions, ReleaseReason.NEW_DEPENDENCIES, rb.getVersion(), options);
129132
}
@@ -132,31 +135,37 @@ public IAction getProductionReleaseActionRoot(Component comp, List<IAction> chil
132135
if (rbs == ReleaseBranchStatus.MDEPS_ACTUAL) {
133136
// need to build
134137
if (actionKind == ActionKind.FORK) {
135-
return new ActionNone(comp, childActions, "nothing to fork");
138+
return new ActionNone(comp, childActions, "nothing to fork. " + rb.getVersion() + " " + rb.getStatus());
136139
}
137140
return new SCMActionBuild(comp, childActions, ReleaseReason.NEW_FEATURES, rb.getVersion(), options);
138141
}
139142

140143
if (hasForkChildActions(childActions)) {
141144
skipAllBuilds(childActions);
142145
if (actionKind == ActionKind.FORK) {
143-
return new ActionNone(comp, childActions, "nothing to build");
146+
return new ActionNone(comp, childActions, "nothing to build. " + rb.getVersion() + " " + rb.getStatus());
144147
}
145-
return new SCMActionFork(comp, childActions, ReleaseReason.NEW_DEPENDENCIES, options);
148+
return new SCMActionFork(comp, childActions, rbs, rbs, options);
146149
}
147150

148-
return new ActionNone(comp, childActions, rbs.toString());
151+
return new ActionNone(comp, childActions, rb.getVersion().toString() + " " + rbs.toString());
149152
}
150153

151154
private boolean needToActualizeMDeps(ReleaseBranch currentCompRB) {
152155
List<Component> mDeps = currentCompRB.getMDeps();
153156
ReleaseBranch mDepRB;
154157
for (Component mDep : mDeps) {
155158
mDepRB = new ReleaseBranch(mDep);
156-
if (mDepRB.getStatus() == ReleaseBranchStatus.MDEPS_ACTUAL) {
159+
ReleaseBranchStatus rbs = mDepRB.getStatus();
160+
if (rbs == ReleaseBranchStatus.MDEPS_ACTUAL) {
157161
if (!mDepRB.getCurrentVersion().equals(mDep.getVersion())) {
158162
return true;
159163
}
164+
165+
} else if (rbs == ReleaseBranchStatus.ACTUAL) {
166+
if (!mDepRB.getCurrentVersion().toPreviousPatch().equals(mDep.getVersion())) {
167+
return true;
168+
}
160169
} else {
161170
if (needToActualizeMDeps(mDepRB)) {
162171
return true;
@@ -194,7 +203,8 @@ private void skipAllBuilds(List<IAction> childActions) {
194203
action = li.next();
195204
skipAllBuilds(action.getChildActions());
196205
if (action instanceof SCMActionBuild) {
197-
li.set(new ActionNone(((SCMActionBuild) action).getComponent(), action.getChildActions(), "build skipped because not all parent components forked"));
206+
li.set(new ActionNone(((SCMActionBuild) action).getComponent(), action.getChildActions(), ((SCMActionBuild) action).getTargetVersion() +
207+
" build skipped because not all parent components forked"));
198208
}
199209
}
200210
}
@@ -229,7 +239,7 @@ private IAction getTagReleaseActionRoot(Component comp, List<IAction> childActio
229239
if (tagsOnRevision.isEmpty()) {
230240
return new SCMActionTagRelease(comp, childActions, options);
231241
}
232-
Version delayedTagVersion = new Version(vcs.getFileContent(rb.getName(), SCMWorkflow.VER_FILE_NAME, delayedRevisionToTag));
242+
Version delayedTagVersion = new Version(vcs.getFileContent(rb.getName(), SCMReleaser.VER_FILE_NAME, delayedRevisionToTag));
233243
for (VCSTag tag : tagsOnRevision) {
234244
if (tag.getTagName().equals(delayedTagVersion.toReleaseString())) {
235245
return new ActionNone(comp, childActions, "tag " + tag.getTagName() + " already exists");
@@ -243,4 +253,8 @@ public static TagDesc getTagDesc(String verStr) {
243253
String tagMessage = tagName + " release";
244254
return new TagDesc(tagName, tagMessage);
245255
}
256+
257+
public List<Option> getOptions() {
258+
return options;
259+
}
246260
}

src/main/java/org/scm4j/wf/VCSFactory.java renamed to src/main/java/org/scm4j/releaser/VCSFactory.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package org.scm4j.wf;
1+
package org.scm4j.releaser;
22

3+
import org.scm4j.releaser.conf.Credentials;
4+
import org.scm4j.releaser.conf.VCSType;
35
import org.scm4j.vcs.GitVCS;
46
import org.scm4j.vcs.api.IVCS;
57
import org.scm4j.vcs.api.workingcopy.IVCSWorkspace;
68
import org.scm4j.vcs.svn.SVNVCS;
7-
import org.scm4j.wf.conf.Credentials;
8-
import org.scm4j.wf.conf.VCSType;
99

1010
public class VCSFactory {
1111

1212
public static IVCS getVCS(VCSType type, Credentials creds, String url, IVCSWorkspace ws) {
13-
IVCS vcs;
13+
IVCS vcs = null;
1414
switch (type) {
1515
case GIT: {
1616
vcs = new GitVCS(ws.getVCSRepositoryWorkspace(url));
@@ -27,9 +27,6 @@ public static IVCS getVCS(VCSType type, Credentials creds, String url, IVCSWorks
2727
creds == null ? null : creds.getPassword());
2828
break;
2929
}
30-
default: {
31-
throw new RuntimeException("Unsupported VCSTtype for repository: " + url);
32-
}
3330
}
3431
return vcs;
3532
}

src/main/java/org/scm4j/wf/actions/ActionAbstract.java renamed to src/main/java/org/scm4j/releaser/actions/ActionAbstract.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package org.scm4j.wf.actions;
1+
package org.scm4j.releaser.actions;
22

3+
import org.scm4j.releaser.conf.Component;
4+
import org.scm4j.releaser.conf.Option;
35
import org.scm4j.vcs.api.IVCS;
4-
import org.scm4j.wf.conf.Component;
5-
import org.scm4j.wf.conf.Option;
66

77
import java.util.List;
88

@@ -35,9 +35,4 @@ public List<IAction> getChildActions() {
3535
public String getName() {
3636
return comp.getName();
3737
}
38-
39-
@Override
40-
public String toString() {
41-
return this.getClass().getSimpleName() + " [" + comp.getName() + "]";
42-
}
4338
}

0 commit comments

Comments
 (0)