List of usage examples for org.eclipse.jgit.lib Constants DOT_GIT_IGNORE
String DOT_GIT_IGNORE
To view the source code for org.eclipse.jgit.lib Constants DOT_GIT_IGNORE.
Click Source Link
From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java
License:Open Source License
private void commit(boolean dir) throws CoreException { try {//from w w w . j av a2s . com Repository local = getLocalRepo(); Git git = new Git(local); String folderPattern = null; String filePattern = null; if (dir) { // add empty dir - http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository File folder = getLocalFile(); File gitignoreFile = new File(folder.getPath() + "/" + Constants.DOT_GIT_IGNORE); // /<folder>/.gitignore gitignoreFile.createNewFile(); String query = getUrl().getQuery(); if (query.equals("/")) { // root filePattern = Constants.DOT_GIT_IGNORE; } else { folderPattern = new Path(query).toString().substring(1); // <folder>/ filePattern = folderPattern + "/" + Constants.DOT_GIT_IGNORE; // <folder>/.gitignore } } else { // /<folder>/<file> IPath f = new Path(getUrl().getQuery()).removeLastSegments(1); // /<folder>/ String s = f.toString().substring(1); // <folder>/ folderPattern = s.equals("") ? null : s; // /<folder>/<file> s = getUrl().getQuery().substring(1); filePattern = s; } // TODO: folder may already exist, no need to add it again AddCommand add = git.add(); if (folderPattern != null) { add.addFilepattern(folderPattern); } add.addFilepattern(filePattern); add.call(); CommitCommand commit = git.commit(); commit.setMessage("auto-commit of " + this); commit.call(); LogHelper.log(new Status(IStatus.INFO, Activator.PI_GIT, 1, "Auto-commit of " + this + " done.", null)); } catch (Exception e) { throw new CoreException(new Status(IStatus.ERROR, Activator.PI_GIT, IStatus.ERROR, e.getMessage(), e)); } }