From fda24259455b53465ef0e7ba587beee036c6ed57 Mon Sep 17 00:00:00 2001 From: Dennis Schumann Date: Mon, 17 Jun 2019 13:56:17 +0200 Subject: [PATCH] Run git commands in init of GitAdapter. Fixes #295 --- .../net/researchgate/release/GitAdapter.groovy | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/net/researchgate/release/GitAdapter.groovy b/src/main/groovy/net/researchgate/release/GitAdapter.groovy index 6d0ad352..f5cc7059 100644 --- a/src/main/groovy/net/researchgate/release/GitAdapter.groovy +++ b/src/main/groovy/net/researchgate/release/GitAdapter.groovy @@ -24,8 +24,8 @@ class GitAdapter extends BaseScmAdapter { private static final String AHEAD = 'ahead' private static final String BEHIND = 'behind' - private final String workingBranch - private final String releaseBranch + private String workingBranch + private String releaseBranch private File workingDirectory @@ -52,9 +52,6 @@ class GitAdapter extends BaseScmAdapter { GitAdapter(Project project, Map attributes) { super(project, attributes) - - workingBranch = gitCurrentBranch() - releaseBranch = extension.pushReleaseVersionBranch ? extension.pushReleaseVersionBranch : workingBranch } @Override @@ -74,6 +71,12 @@ class GitAdapter extends BaseScmAdapter { @Override void init() { + workingBranch = gitCurrentBranch() + if (extension.pushReleaseVersionBranch) { + releaseBranch = extension.pushReleaseVersionBranch + } else { + releaseBranch = workingBranch + } if (extension.git.requireBranch) { if (!(workingBranch ==~ extension.git.requireBranch)) { throw new GradleException("Current Git branch is \"$workingBranch\" and not \"${ extension.git.requireBranch }\".")