Skip to content

Commit

Permalink
Merge pull request #69 from egineering-llc/hotfix/1.7.1
Browse files Browse the repository at this point in the history
Hotfix 1.7.1 - Support Branch execution pruning.
  • Loading branch information
bvarner authored Feb 28, 2017
2 parents 12f5c79 + bb5c968 commit a002a6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>com.e-gineering</groupId>
<artifactId>gitflow-helper-maven-plugin</artifactId>

<version>1.7.0</version>
<version>1.7.1</version>
<packaging>maven-plugin</packaging>

<name>gitflow-helper-maven-plugin</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti

// Look for a gitflow-helper-maven-plugin, so we can determine what the gitBranchExpression and masterBranchPattern are...
String masterBranchPattern = null;
String supportBranchPattern = null;

String gitBranchExpression = null;
boolean pluginFound = false;
Expand Down Expand Up @@ -88,6 +89,10 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
masterBranchPattern = extractPluginConfigValue("masterBranchPattern", plugin);
}

if (supportBranchPattern == null) {
supportBranchPattern = extractPluginConfigValue("supportBranchPattern", plugin);
}

if (gitBranchExpression == null) {
gitBranchExpression = extractPluginConfigValue("gitBranchExpression", plugin);
}
Expand All @@ -109,10 +114,16 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
if (pluginFound) {
if (masterBranchPattern == null) {
logger.debug("Using default master branch Pattern.");
masterBranchPattern = "origin/master";
masterBranchPattern = "(origin/)?master";
}
logger.debug("Master Branch Pattern: " + masterBranchPattern);

if (supportBranchPattern == null) {
logger.debug("Using default support branch Pattern.");
supportBranchPattern = "(origin/)?support/(.*)";
}
logger.debug("Support Branch Pattern: " + supportBranchPattern);

if (gitBranchExpression == null) {
logger.debug("Using default branch expression resolver.");
gitBranchExpression = ScmUtils.resolveBranchOrExpression(scmManager, session.getTopLevelProject(), new DefaultLog(logger));
Expand All @@ -124,10 +135,17 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
String gitBranch = pr.resolveValue(gitBranchExpression, session.getCurrentProject().getProperties(), systemEnvVars);
logger.info("gitflow-helper-maven-plugin: Build Extension resolved gitBranchExpression: " + gitBranchExpression + " to: " + gitBranch);

// Test to see if the current GIT_BRANCH matches the masterBranchPattern...
// If the current git branch matches the master or support branch, prune the build plugin list.
boolean pruneBuild = false;
if (gitBranch != null && gitBranch.matches(masterBranchPattern)) {
logger.info("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [" + gitBranch + "] matches masterBranchPattern: [" + masterBranchPattern + "]");
pruneBuild = true;
} else if (gitBranch != null && gitBranch.matches(supportBranchPattern)) {
logger.info("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [" + gitBranch + "] matches supportBranchPattern: [" + supportBranchPattern + "]");
pruneBuild = true;
}

if (pruneBuild) {
for (MavenProject project : session.getProjects()) {
// Drop all the plugins from the build except for the gitflow-helper-maven-plugin, or plugins we
// invoked goals for which could be mapped back to plugins in our project build.
Expand Down

0 comments on commit a002a6a

Please sign in to comment.