Example usage for org.eclipse.jgit.lib Constants DOT_GIT

List of usage examples for org.eclipse.jgit.lib Constants DOT_GIT

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants DOT_GIT.

Prototype

String DOT_GIT

To view the source code for org.eclipse.jgit.lib Constants DOT_GIT.

Click Source Link

Document

Default name for the Git repository directory

Usage

From source file:jbyoshi.gitupdate.GitUpdate.java

License:Apache License

private static void update(File repoDir, Task root) {
    try {/*w ww .j a  v  a2  s .  co  m*/
        if (!repoDir.isDirectory()) {
            return;
        }
        try (Repository repo = new RepositoryBuilder().setWorkTree(repoDir).setMustExist(true).build()) {
            update(repo, root);
        }
    } catch (RepositoryNotFoundException e) {
        if (repoDir.getName().equals(Constants.DOT_GIT)) {
            repoDir = repoDir.getParentFile();
        }
        try {
            repoDir = repoDir.toPath().toRealPath().toFile();
        } catch (IOException e1) {
            repoDir = repoDir.toPath().normalize().toFile();
        }
        if (updated.add(repoDir)) {
            root.report.newChild(repoDir.getName() + " - not a Git repository");
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:jbyoshi.gitupdate.GitUpdate.java

License:Apache License

private static void update(Repository repo, Task root) {
    File dir = repo.getDirectory();
    if (dir.getName().equals(Constants.DOT_GIT)) {
        dir = dir.getParentFile();/* w  w  w.ja va  2 s. c  o  m*/
    }
    try {
        dir = dir.toPath().toRealPath().toFile();
    } catch (IOException e) {
        dir = dir.toPath().normalize().toFile();
    }
    if (!updated.add(dir)) {
        return;
    }

    List<String> failures = new ArrayList<>();

    try {
        if (SubmoduleWalk.containsGitModulesFile(repo)) {
            try (SubmoduleWalk submodules = SubmoduleWalk.forIndex(repo)) {
                while (submodules.next()) {
                    if (submodules.getRepository() == null) {
                        failures.add("Submodule " + submodules.getDirectory().getName() + " - does not exist");
                    } else {
                        update(submodules.getRepository(), root);
                    }
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    Task repoTask = root.newChild(dir.getName());
    for (String error : failures) {
        repoTask.report.newChild(error).error();
    }

    try (Git git = Git.wrap(repo)) {
        for (Processor processor : processors) {
            try {
                processor.registerTasks(repo, git, repoTask);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:net.erdfelt.android.sdkfido.git.internal.InternalGit.java

License:Apache License

public InternalGit(File workDirectory, GitMirrors mirrors) throws GitException {
    try {/* w  ww . ja  v a2  s  .  c o m*/
        this.mirrors = mirrors;
        this.repoDirectory = new File(workDirectory, Constants.DOT_GIT);
        this.repo = new FileRepository(repoDirectory);
    } catch (IOException e) {
        throw new GitException(e.getMessage(), e);
    }
}

From source file:org.commonjava.gitwrap.GitRepository.java

License:Open Source License

public GitRepository(final File workDir, final boolean create) throws IOException {
    super(new File(workDir, Constants.DOT_GIT), create, workDir);
}

From source file:org.eclipse.che.git.impl.jgit.JGitConnectionFactory.java

License:Open Source License

private static Repository createRepository(File workDir) throws GitException {
    try {//from w  ww. j a  va  2s. c om
        return new FileRepository(new File(workDir, Constants.DOT_GIT));
    } catch (IOException e) {
        throw new GitException(e.getMessage(), e);
    }
}

From source file:org.eclipse.egit.core.Activator.java

License:Open Source License

private void registerPreDeleteResourceChangeListener() {
    if (preDeleteProjectListener == null) {
        preDeleteProjectListener = new IResourceChangeListener() {

            public void resourceChanged(IResourceChangeEvent event) {
                IResource resource = event.getResource();
                if (resource instanceof IProject) {
                    IProject project = (IProject) resource;
                    if (RepositoryProvider.getProvider(project) instanceof GitProvider) {
                        IResource dotGit = project.findMember(Constants.DOT_GIT);
                        if (dotGit != null && dotGit.getType() == IResource.FOLDER)
                            GitProjectData.reconfigureWindowCache();
                    }/*from www.j a va  2 s. com*/
                }
            }
        };
        ResourcesPlugin.getWorkspace().addResourceChangeListener(preDeleteProjectListener,
                IResourceChangeEvent.PRE_DELETE);
    }
}

From source file:org.eclipse.egit.core.GitMoveDeleteHookTest.java

License:Open Source License

private TestProject initRepoInsideProjectInsideWorkspace() throws IOException, CoreException {
    TestProject project = new TestProject(true, "Project-1", true, workspaceSupplement);
    File gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testDirs.add(gitDir);/*from w w w.  jav a 2s  .co  m*/
    testRepository = new TestRepository(gitDir);
    repository = testRepository.getRepository();
    testRepository.connect(project.getProject());
    registerWorkspaceRelativeTestDir("Project-1");
    return project;
}

From source file:org.eclipse.egit.core.GitMoveDeleteHookTest.java

License:Open Source License

private TestProject initRepoInsideProjectOutsideWorkspace() throws IOException, CoreException {
    TestProject project = new TestProject(true, "Project-1", false, workspaceSupplement);
    File gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testDirs.add(gitDir);/* ww  w .  jav a 2  s .c  o m*/
    testRepository = new TestRepository(gitDir);
    repository = testRepository.getRepository();
    testRepository.connect(project.getProject());
    return project;
}

From source file:org.eclipse.egit.core.GitMoveDeleteHookTest.java

License:Open Source License

private TestProject initRepoAboveProject(String srcParent, String d, boolean insidews)
        throws IOException, CoreException {
    registerWorkspaceRelativeTestDir(srcParent);
    TestProject project = new TestProject(true, srcParent + "Project-1", insidews, workspaceSupplement);
    File gd = new File(insidews ? workspace : workspaceSupplement, d);

    File gitDir = new File(gd, Constants.DOT_GIT);
    testDirs.add(gitDir);//from  ww w  .  j  a va 2 s.  c  om
    testRepository = new TestRepository(gitDir);
    repository = testRepository.getRepository();
    testRepository.connect(project.getProject());
    return project;
}

From source file:org.eclipse.egit.core.op.CloneOperation.java

License:Open Source License

/**
 * Create a new clone operation.//w w w  . ja  v  a 2  s .com
 *
 * @param uri
 *            remote we should fetch from.
 * @param allSelected
 *            true when all branches have to be fetched (indicates wildcard
 *            in created fetch refspec), false otherwise.
 * @param selectedBranches
 *            collection of branches to fetch. Ignored when allSelected is
 *            true.
 * @param workdir
 *            working directory to clone to. The directory may or may not
 *            already exist.
 * @param branch
 *            branch to initially clone from.
 * @param remoteName
 *            name of created remote config as source remote (typically
 *            named "origin").
 * @param timeout timeout in seconds
 */
public CloneOperation(final URIish uri, final boolean allSelected, final Collection<Ref> selectedBranches,
        final File workdir, final String branch, final String remoteName, int timeout) {
    this.uri = uri;
    this.allSelected = allSelected;
    this.selectedBranches = selectedBranches;
    this.workdir = workdir;
    this.gitdir = new File(workdir, Constants.DOT_GIT);
    this.branch = branch;
    this.remoteName = remoteName;
    this.timeout = timeout;
}