Skip to content

Commit

Permalink
Run git commands in init of GitAdapter. Fixes #295
Browse files Browse the repository at this point in the history
  • Loading branch information
Hillkorn committed Jun 17, 2019
1 parent 3c6987b commit fda2425
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/groovy/net/researchgate/release/GitAdapter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -52,9 +52,6 @@ class GitAdapter extends BaseScmAdapter {

GitAdapter(Project project, Map<String, Object> attributes) {
super(project, attributes)

workingBranch = gitCurrentBranch()
releaseBranch = extension.pushReleaseVersionBranch ? extension.pushReleaseVersionBranch : workingBranch
}

@Override
Expand All @@ -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 }\".")
Expand Down

0 comments on commit fda2425

Please sign in to comment.