Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.springframework.roo.addon.git;
 
 import java.io.File;
 
 import  org.eclipse.jgit.lib.Constants;
Listener for Shell events to support automatic Git repository commits.

Author(s):
Stefan Schmidt
Since:
1.1
public class GitShellEventListener implements ShellStatusListener {
    @Reference private Shell shell;
    protected void activate(final ComponentContext context) {
        .addShellStatusListener(this);
    }
    protected void deactivate(final ComponentContext context) {
        .removeShellStatusListener(this);
    }
    private boolean isGitEnabled() {
        return new File(.getRoot(), Constants.DOT_GIT)
                .isDirectory();
    }
    public void onShellStatusChange(final ShellStatus oldStatus,
            final ShellStatus newStatus) {
        if (newStatus.getStatus().equals(.)
                && isGitEnabled() && .isAutomaticCommit()) {
            .commitAllChanges(newStatus.getMessage());
        }
    }
New to GrepCode? Check out our FAQ X