Package org.nbgit

Examples of org.nbgit.Git


        }
        return f1;
    }

    public void performAction(ActionEvent e) {
        final Git git = Git.getInstance();

        File[] files = context.getRootFiles().toArray(new File[context.getRootFiles().size()]);
        if (files == null || files.length == 0) {
            return;     // If there is a .git directory in an ancestor of any of the files in
        // the context we fail.
        }
        for (File file : files) {
            if (!file.isDirectory()) {
                file = file.getParentFile();
            }
            if (git.getTopmostManagedParent(file) != null) {
                Git.LOG.log(Level.SEVERE, "Found .git directory in ancestor of {0} ", // NOI18N
                        file);
                return;
            }
        }

        final Project proj = GitUtils.getProject(context);
        File projFile = GitUtils.getProjectFile(proj);

        if (projFile == null) {
            OutputLogger logger = OutputLogger.getLogger(Git.GIT_OUTPUT_TAB_TITLE);
            logger.outputInRed(NbBundle.getMessage(InitAction.class, "MSG_CREATE_TITLE")); // NOI18N
            logger.outputInRed(NbBundle.getMessage(InitAction.class, "MSG_CREATE_TITLE_SEP")); // NOI18N
            logger.outputInRed(
                    NbBundle.getMessage(InitAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N
            logger.output(""); // NOI18N
            JOptionPane.showMessageDialog(null,
                    NbBundle.getMessage(InitAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW"),// NOI18N
                    NbBundle.getMessage(InitAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N
                    JOptionPane.INFORMATION_MESSAGE);
            logger.closeLog();
            return;
        }
        String projName = GitProjectUtils.getProjectName(projFile);

        File rootDir = getCommonAncestor(files);
        final File root = getCommonAncestor(rootDir, projFile);
        if (root == null) {
            return;
        }
        final String prjName = projName;
        final Repository repo = git.getRepository(root);

        RequestProcessor rp = git.getRequestProcessor(root.getAbsolutePath());

        GitProgressSupport supportCreate = new GitProgressSupport() {

            public void perform() {
                try {
                    OutputLogger logger = getLogger();
                    logger.outputInRed(
                            NbBundle.getMessage(InitAction.class,
                            "MSG_CREATE_TITLE")); // NOI18N
                    logger.outputInRed(
                            NbBundle.getMessage(InitAction.class,
                            "MSG_CREATE_TITLE_SEP")); // NOI18N
                    logger.output(
                            NbBundle.getMessage(InitAction.class,
                            "MSG_CREATE_INIT", prjName, root)); // NOI18N

                    repo.create();
                } catch (IOException ex) {
                    notifyLater(ex);
                }
            }
        };
        supportCreate.start(rp, root.getAbsolutePath(),
                org.openide.util.NbBundle.getMessage(InitAction.class, "MSG_Create_Progress")); // NOI18N

        GitProgressSupport supportAdd = new GitProgressSupport() {

            public void perform() {
                OutputLogger logger = getLogger();
                try {
                    List<File> files = getFileList(repo, root);
                    IndexBuilder.create(repo).
                            log(logger).
                            addAll(files).
                            write();

                    logger.output(
                            NbBundle.getMessage(InitAction.class,
                            "MSG_CREATE_ADD", files.size(), root.getAbsolutePath())); // NOI18N
                    logger.output(""); // NOI18N
                    logger.outputInRed(NbBundle.getMessage(InitAction.class, "MSG_CREATE_DONE_WARNING")); // NOI18N
                } catch (IOException ex) {
                    notifyLater(ex);
                } finally {
                    logger.outputInRed(NbBundle.getMessage(InitAction.class, "MSG_CREATE_DONE")); // NOI18N
                    logger.output(""); // NOI18N
                }
            }
        };

        supportAdd.start(rp, root.getAbsolutePath(),
                org.openide.util.NbBundle.getMessage(InitAction.class, "MSG_Create_Add_Progress")); // NOI18N

        GitProgressSupport supportStatus = new StatusTask(context) {

            @Override
            public void performAfter() {
                git.versionedFilesChanged();
                git.refreshAllAnnotations();
            }

        };

        supportStatus.start(rp, root.getAbsolutePath(),
View Full Code Here


     */
    public static boolean isLocallyAdded(File file) {
        if (file == null) {
            return false;
        }
        Git git = Git.getInstance();

        if ((git.getStatusCache().getStatus(file).getStatus() & StatusInfo.STATUS_VERSIONED_ADDEDLOCALLY) != 0) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

     */
    public static File getRootFile(VCSContext context) {
        if (context == null) {
            return null;
        }
        Git git = Git.getInstance();
        File[] files = context.getRootFiles().toArray(new File[context.getRootFiles().size()]);
        if (files == null || files.length == 0) {
            return null;
        }
        return git.getTopmostManagedParent(files[0]);
    }
View Full Code Here

        }
        String shortPath = file.getAbsolutePath();
        if (shortPath == null) {
            return NbBundle.getMessage(SyncFileNode.class, "LBL_Location_NotInRepository");
        }
        Git git = Git.getInstance();
        File rootManagedFolder = git.getTopmostManagedParent(file);
        if (rootManagedFolder == null) {
            return NbBundle.getMessage(SyncFileNode.class, "LBL_Location_NotInRepository");
        }
        String root = rootManagedFolder.getAbsolutePath();
        if (shortPath.startsWith(root) && shortPath.length() > root.length()) {
View Full Code Here

                        this.cancel();
                    }
                    doCheckout(repo, branch, logger);

                    if (isLocalClone) {
                        Git git = Git.getInstance();
                        ProjectManager projectManager = ProjectManager.getDefault();
                        File normalizedCloneFolder = FileUtil.normalizeFile(target);
                        File cloneProjFile;
                        if (!projIsRepos) {
                            String name = (projFile != null)
                                    ? projFile.getAbsolutePath().substring(source.getPath().length() + 1)
                                    : target.getAbsolutePath();
                            cloneProjFile = new File(normalizedCloneFolder, name);
                        } else {
                            cloneProjFile = normalizedCloneFolder;
                        }
                        openProject(cloneProjFile, projectManager, git);
                    } else if (scanForProjects) {
                        CloneCompleted cc = new CloneCompleted(target);
                        if (isCanceled()) {
                            return;
                        }
                        cc.scanForProjects(this);
                    }

                } catch (URISyntaxException usex) {
                    notifyLater(usex);
                } catch (IOException ex) {
                    notifyLater(ex);
                } finally {
                    if (!isLocalClone) {
                        logger.outputInRed(NbBundle.getMessage(CloneAction.class, "MSG_CLONE_DONE")); // NOI18N
                        logger.output(""); // NOI18N
                    }
                }
            }

            private void openProject(final File cloneProjFile, final ProjectManager projectManager, final Git git) {
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        // Open and set focus on the cloned project if possible
                        OutputLogger logger = getLogger();
                        try {
                            FileObject cloneProj = FileUtil.toFileObject(cloneProjFile);
                            Project proj = null;
                            if (cloneProjFile != null && cloneProj != null) {
                                proj = projectManager.findProject(cloneProj);
                            }
                            if (proj != null) {
                                GitProjectUtils.openProject(proj, this, false);
                                                      // TODO: GitModuleConfig.getDefault().getSetMainProject()
                                git.versionedFilesChanged();
                                git.refreshAllAnnotations();
                            } else {
                                logger.outputInRed(NbBundle.getMessage(CloneAction.class, "MSG_EXTERNAL_CLONE_PRJ_NOT_FOUND_CANT_SETASMAIN")); // NOI18N
                            }
                        } catch (IOException ioe) {
                            notifyLater(ioe);
View Full Code Here

TOP

Related Classes of org.nbgit.Git

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.