Ref masterRef = git.getRepository()
.getRef("master");
if (null != masterRef)
commitId = ObjectId.toString(masterRef.getObjectId());
Status status = git.status().call();
boolean pushAhead = false;
if (null != commitId && status.isClean()) {
versionLabel = lookupVersionLabelForCommitId(commitId);
if (null == versionLabel) {
getLog().info("No Changes. However, we've didn't get something close in AWS Elastic Beanstalk and we're pushing ahead");
pushAhead = true;
} else {
getLog().info("No Changes. However, we've got something close in AWS Elastic Beanstalk and we're continuing");
project.getProperties().put("beanstalk.versionLabel", versionLabel);
return null;
}
}
if (!pushAhead) {
// Asks for Existing Files to get added
git.add().setUpdate(true).addFilepattern(".").call();
// Now as for any new files (untracked)
AddCommand addCommand = git.add();
if (!status.getUntracked().isEmpty()) {
for (String s : status.getUntracked()) {
getLog().info("Adding file " + s);
addCommand.addFilepattern(s);
}
addCommand.call();