Search in sources :

Example 1 with GitCommitTask

use of org.shipkit.gradle.git.GitCommitTask in project shipkit by mockito.

the class GitPlugin method registerChangesForCommitIfApplied.

public static void registerChangesForCommitIfApplied(final List<File> changedFiles, final String changeDescription, final Task changingTask) {
    final Project project = changingTask.getProject();
    project.getPlugins().withType(GitPlugin.class, new Action<GitPlugin>() {

        @Override
        public void execute(GitPlugin gitPushPlugin) {
            GitCommitTask gitCommitTask = (GitCommitTask) project.getTasks().findByName(GitPlugin.GIT_COMMIT_TASK);
            gitCommitTask.addChange(changedFiles, changeDescription, changingTask);
        }
    });
}
Also used : Project(org.gradle.api.Project) GitCommitTask(org.shipkit.gradle.git.GitCommitTask)

Example 2 with GitCommitTask

use of org.shipkit.gradle.git.GitCommitTask in project shipkit by mockito.

the class GitPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    TaskMaker.task(project, GIT_COMMIT_TASK, GitCommitTask.class, new Action<GitCommitTask>() {

        public void execute(final GitCommitTask t) {
            t.setDescription("Commits all changed files using generic --author and aggregated commit message");
            t.setGitUserName(conf.getGit().getUser());
            t.setGitUserEmail(conf.getGit().getEmail());
            t.setCommitMessagePostfix(conf.getGit().getCommitMessagePostfix());
        }
    });
    TaskMaker.task(project, GIT_TAG_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.mustRunAfter(GIT_COMMIT_TASK);
            final String tag = GitUtil.getTag(conf, project);
            t.setDescription("Creates new version tag '" + tag + "'");
            t.execCommand(execCommand("Creating tag", "git", "tag", "-a", tag, "-m", GitUtil.getCommitMessage("Created new tag " + tag, conf.getGit().getCommitMessagePostfix())));
        }
    });
    TaskMaker.task(project, GIT_PUSH_TASK, GitPushTask.class, new Action<GitPushTask>() {

        public void execute(final GitPushTask t) {
            t.setDescription("Pushes automatically created commits to remote repo.");
            t.mustRunAfter(GIT_COMMIT_TASK);
            t.mustRunAfter(GIT_TAG_TASK);
            t.dependsOn(GitBranchPlugin.IDENTIFY_GIT_BRANCH);
            t.getTargets().add(GitUtil.getTag(conf, project));
            t.setDryRun(conf.isDryRun());
            GitUrlInfo info = new GitUrlInfo(conf);
            t.setUrl(info.getGitUrl());
            t.setSecretValue(info.getWriteToken());
            project.getPlugins().apply(GitBranchPlugin.class).provideBranchTo(t, new Action<String>() {

                @Override
                public void execute(String branch) {
                    t.getTargets().add(branch);
                }
            });
        }
    });
    final Task performPush = TaskMaker.task(project, PERFORM_GIT_PUSH_TASK, Task.class, new Action<Task>() {

        public void execute(final Task t) {
            t.setDescription("Performs gitCommit, gitTag and gitPush tasks and all tasks dependent on them.");
            t.dependsOn(GIT_COMMIT_TASK, GIT_TAG_TASK, GIT_PUSH_TASK);
        }
    });
    TaskMaker.task(project, PERFORM_GIT_COMMIT_CLEANUP_TASK, Task.class, new Action<Task>() {

        public void execute(final Task t) {
            t.setDescription("Performs " + SOFT_RESET_COMMIT_TASK + " and " + GIT_STASH_TASK + " tasks.");
            t.dependsOn(SOFT_RESET_COMMIT_TASK, GIT_STASH_TASK);
            t.mustRunAfter(performPush);
        }
    });
    TaskMaker.task(project, GIT_STASH_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Stashes current changes");
            t.execCommand(execCommand("Stashing changes", "git", "stash"));
            t.mustRunAfter(SOFT_RESET_COMMIT_TASK);
        }
    });
    TaskMaker.task(project, SOFT_RESET_COMMIT_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Removes last commit, using 'reset --soft HEAD~'");
            t.execCommand(execCommand("Removing last commit", "git", "reset", "--soft", "HEAD~"));
        }
    });
    TaskMaker.task(project, TAG_CLEANUP_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Deletes version tag '" + getTag(conf, project) + "'");
            t.execCommand(execCommand("Deleting version tag", "git", "tag", "-d", getTag(conf, project)));
            t.mustRunAfter(performPush);
        }
    });
}
Also used : Action(org.gradle.api.Action) ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask) IdentifyGitBranchTask(org.shipkit.gradle.git.IdentifyGitBranchTask) GitCommitTask(org.shipkit.gradle.git.GitCommitTask) Task(org.gradle.api.Task) GitPushTask(org.shipkit.gradle.git.GitPushTask) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask) GitPushTask(org.shipkit.gradle.git.GitPushTask) GitCommitTask(org.shipkit.gradle.git.GitCommitTask)

Aggregations

GitCommitTask (org.shipkit.gradle.git.GitCommitTask)2 Action (org.gradle.api.Action)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)1 ShipkitExecTask (org.shipkit.gradle.exec.ShipkitExecTask)1 GitPushTask (org.shipkit.gradle.git.GitPushTask)1 IdentifyGitBranchTask (org.shipkit.gradle.git.IdentifyGitBranchTask)1 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)1