Package com.gitblit.models.PathModel

Examples of com.gitblit.models.PathModel.PathChangeModel


      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathChangeModel> item) {
        final PathChangeModel entry = item.getModelObject();
        Label changeType = new Label("changeType", "");
        WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
        setChangeTypeTooltip(changeType, entry.changeType);
        item.add(changeType);
        item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));

        boolean hasSubmodule = false;
        String submodulePath = null;
        if (entry.isTree()) {
          // tree
          item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, entry.commitId, entry.path)));
        } else if (entry.isSubmodule()) {
          // submodule
          String submoduleId = entry.objectId;
          SubmoduleModel submodule = getSubmodule(entry.path);
          submodulePath = submodule.gitblitPath;
          hasSubmodule = submodule.hasSubmodule;

          // add relative link
          item.add(new LinkPanel("pathName", "list", entry.path + " @ " + getShortObjectId(submoduleId), "#" + entry.path));
        } else {
          // add relative link
          item.add(new LinkPanel("pathName", "list", entry.path, "#" + entry.path));
        }

        // quick links
        if (entry.isSubmodule()) {
          item.add(new ExternalLink("raw", "").setEnabled(false));
          // submodule
          item.add(new ExternalLink("patch", "").setEnabled(false));
          item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
              .newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
View Full Code Here


      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathChangeModel> item) {
        final PathChangeModel entry = item.getModelObject();
        Label changeType = new Label("changeType", "");
        WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
        setChangeTypeTooltip(changeType, entry.changeType);
        item.add(changeType);

        boolean hasSubmodule = false;
        String submodulePath = null;
        if (entry.isTree()) {
          // tree
          item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, currentPatchset.tip, entry.path), true));
          item.add(new Label("diffStat").setVisible(false));
        } else if (entry.isSubmodule()) {
          // submodule
          String submoduleId = entry.objectId;
          SubmoduleModel submodule = getSubmodule(entry.path);
          submodulePath = submodule.gitblitPath;
          hasSubmodule = submodule.hasSubmodule;

          item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
              getShortObjectId(submoduleId), TreePage.class,
              WicketUtils.newPathParameter(submodulePath, submoduleId, ""), true).setEnabled(hasSubmodule));
          item.add(new Label("diffStat").setVisible(false));
        } else {
          // blob
          String displayPath = entry.path;
          String path = entry.path;
          if (entry.isSymlink()) {
            RevCommit commit = JGitUtils.getCommit(getRepository(), PatchsetCommand.getTicketBranch(ticket.number));
            path = JGitUtils.getStringContent(getRepository(), commit.getTree(), path);
            displayPath = entry.path + " -> " + path;
          }

          if (entry.changeType.equals(ChangeType.ADD)) {
            // add show view
            item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
                WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
          } else if (entry.changeType.equals(ChangeType.DELETE)) {
            // delete, show label
            item.add(new Label("pathName", displayPath));
          } else {
            // mod, show diff
            item.add(new LinkPanel("pathName", "list", displayPath, BlobDiffPage.class,
                WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
          }
          item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));
        }

        // quick links
        if (entry.isSubmodule()) {
          // submodule
          item.add(setNewTarget(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path)))
              .setEnabled(!entry.changeType.equals(ChangeType.ADD)));
          item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
View Full Code Here

        try {
          tw.addTree(commit.getTree());
          tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
          while (tw.next()) {
            if (tw.getPathString().equals(path)) {
              matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw
                .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),
                ChangeType.MODIFY);
            }
          }
        } catch (Exception e) {
View Full Code Here

      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathChangeModel> item) {
        final PathChangeModel entry = item.getModelObject();
        Label changeType = new Label("changeType", "");
        WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
        setChangeTypeTooltip(changeType, entry.changeType);
        item.add(changeType);
        item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));

        boolean hasSubmodule = false;
        String submodulePath = null;
        if (entry.isTree()) {
          // tree
          item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, entry.commitId, entry.path)));
        } else if (entry.isSubmodule()) {
          // submodule
          String submoduleId = entry.objectId;
          SubmoduleModel submodule = getSubmodule(entry.path);
          submodulePath = submodule.gitblitPath;
          hasSubmodule = submodule.hasSubmodule;

          item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
              getShortObjectId(submoduleId), TreePage.class,
              WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
        } else {
          // blob
          String displayPath = entry.path;
          String path = entry.path;
          if (entry.isSymlink()) {
            path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
            displayPath = entry.path + " -> " + path;
          }
          item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
              WicketUtils
                  .newPathParameter(repositoryName, entry.commitId, path)));
        }


        // quick links
        if (entry.isSubmodule()) {
          item.add(new ExternalLink("raw", "").setEnabled(false));

          // submodule
          item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path))
View Full Code Here

        private static final long serialVersionUID = 1L;
        int counter;

        @Override
        public void populateItem(final Item<PathChangeModel> item) {
          final PathChangeModel entry = item.getModelObject();
          Label changeType = new Label("changeType", "");
          WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
          setChangeTypeTooltip(changeType, entry.changeType);
          item.add(changeType);
          item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));

          boolean hasSubmodule = false;
          String submodulePath = null;
          if (entry.isTree()) {
            // tree
            item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
                WicketUtils
                .newPathParameter(repositoryName, endId, entry.path)));
          } else if (entry.isSubmodule()) {
            // submodule
            String submoduleId = entry.objectId;
            SubmoduleModel submodule = getSubmodule(entry.path);
            submodulePath = submodule.gitblitPath;
            hasSubmodule = submodule.hasSubmodule;

            // add relative link
            item.add(new LinkPanel("pathName", "list", entry.path + " @ " + getShortObjectId(submoduleId), "#" + entry.path));
          } else {
            // add relative link
            item.add(new LinkPanel("pathName", "list", entry.path, "#" + entry.path));
          }

          // quick links
          if (entry.isSubmodule()) {
            // submodule
            item.add(new ExternalLink("patch", "").setEnabled(false));
            item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
                .newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
            item.add(new ExternalLink("raw", "").setEnabled(false));
View Full Code Here

        TreeWalk tw = new TreeWalk(repository);
        tw.reset();
        tw.setRecursive(true);
        tw.addTree(commit.getTree());
        while (tw.next()) {
          list.add(new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw
              .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),
              ChangeType.ADD));
        }
        tw.release();
      } else {
        RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
        DiffStatFormatter df = new DiffStatFormatter(commit.getName());
        df.setRepository(repository);
        df.setDiffComparator(RawTextComparator.DEFAULT);
        df.setDetectRenames(true);
        List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree());
        for (DiffEntry diff : diffs) {
          // create the path change model
          PathChangeModel pcm = PathChangeModel.from(diff, commit.getName());

          if (calculateDiffStat) {
            // update file diffstats
            df.format(diff);
            PathChangeModel pathStat = df.getDiffStat().getPath(pcm.path);
            if (pathStat != null) {
              pcm.insertions = pathStat.insertions;
              pcm.deletions = pathStat.deletions;
            }
          }
View Full Code Here

      df.setDiffComparator(RawTextComparator.DEFAULT);
      df.setDetectRenames(true);

      List<DiffEntry> diffEntries = df.scan(startCommit.getTree(), endCommit.getTree());
      for (DiffEntry diff : diffEntries) {
        PathChangeModel pcm = PathChangeModel.from(diff,  endCommit.getName());
        list.add(pcm);
      }
      Collections.sort(list);
    } catch (Throwable t) {
      error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
View Full Code Here

      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathChangeModel> item) {
        final PathChangeModel entry = item.getModelObject();
        Label changeType = new Label("changeType", "");
        WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
        setChangeTypeTooltip(changeType, entry.changeType);
        item.add(changeType);

        boolean hasSubmodule = false;
        String submodulePath = null;
        if (entry.isTree()) {
          // tree
          item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, currentPatchset.tip, entry.path), true));
          item.add(new Label("diffStat").setVisible(false));
        } else if (entry.isSubmodule()) {
          // submodule
          String submoduleId = entry.objectId;
          SubmoduleModel submodule = getSubmodule(entry.path);
          submodulePath = submodule.gitblitPath;
          hasSubmodule = submodule.hasSubmodule;

          item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
              getShortObjectId(submoduleId), TreePage.class,
              WicketUtils.newPathParameter(submodulePath, submoduleId, ""), true).setEnabled(hasSubmodule));
          item.add(new Label("diffStat").setVisible(false));
        } else {
          // blob
          String displayPath = entry.path;
          String path = entry.path;
          if (entry.isSymlink()) {
            RevCommit commit = JGitUtils.getCommit(getRepository(), PatchsetCommand.getTicketBranch(ticket.number));
            path = JGitUtils.getStringContent(getRepository(), commit.getTree(), path);
            displayPath = entry.path + " -> " + path;
          }

          if (entry.changeType.equals(ChangeType.ADD)) {
            // add show view
            item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
                WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
          } else if (entry.changeType.equals(ChangeType.DELETE)) {
            // delete, show label
            item.add(new Label("pathName", displayPath));
          } else {
            // mod, show diff
            item.add(new LinkPanel("pathName", "list", displayPath, BlobDiffPage.class,
                WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
          }
          item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));
        }

        // quick links
        if (entry.isSubmodule()) {
          // submodule
          item.add(setNewTarget(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path)))
              .setEnabled(!entry.changeType.equals(ChangeType.ADD)));
          item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
View Full Code Here

      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathChangeModel> item) {
        final PathChangeModel entry = item.getModelObject();
        Label changeType = new Label("changeType", "");
        WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
        setChangeTypeTooltip(changeType, entry.changeType);
        item.add(changeType);
        item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));

        boolean hasSubmodule = false;
        String submodulePath = null;
        if (entry.isTree()) {
          // tree
          item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, entry.commitId, entry.path)));
        } else if (entry.isSubmodule()) {
          // submodule
          String submoduleId = entry.objectId;
          SubmoduleModel submodule = getSubmodule(entry.path);
          submodulePath = submodule.gitblitPath;
          hasSubmodule = submodule.hasSubmodule;

          item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
              getShortObjectId(submoduleId), TreePage.class,
              WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
        } else {
          // blob
          String displayPath = entry.path;
          String path = entry.path;
          if (entry.isSymlink()) {
            path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
            displayPath = entry.path + " -> " + path;
          }
          item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
              WicketUtils
                  .newPathParameter(repositoryName, entry.commitId, path)));
        }


        // quick links
        if (entry.isSubmodule()) {
          item.add(new ExternalLink("raw", "").setEnabled(false));

          // submodule
          item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path))
View Full Code Here

    public DiffStat(String commitId) {
      this.commitId = commitId;
    }

    public PathChangeModel addPath(DiffEntry entry) {
      PathChangeModel pcm = PathChangeModel.from(entry, commitId);
      paths.add(pcm);
      return pcm;
    }
View Full Code Here

TOP

Related Classes of com.gitblit.models.PathModel.PathChangeModel

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.