Package com.gitblit.models

Examples of com.gitblit.models.RefLogEntry


        if (!refMap.containsKey(ref)) {
          refMap.put(ref, new ArrayList<RefLogEntry>());
        }

        // construct new ref-specific ref change entry
        RefLogEntry refChange;
        if (entry instanceof DailyLogEntry) {
          // simulated reflog from commits grouped by date
          refChange = new DailyLogEntry(entry.repository, entry.date);
        } else {
          // real reflog entry
          refChange = new RefLogEntry(entry.repository, entry.date, entry.user);
        }
        refChange.updateRef(ref, entry.getChangeType(ref), entry.getOldId(ref), entry.getNewId(ref));
        refChange.addCommits(entry.getCommits(ref));
        refMap.get(ref).add(refChange);
      }
    }

    // merge individual ref changes into master list
View Full Code Here


        if (!refMap.containsKey(ref)) {
          refMap.put(ref, new ArrayList<RefLogEntry>());
        }

                // construct new ref-specific log entry
                RefLogEntry refPush = new RefLogEntry(entry.repository, entry.date, entry.user);
                refPush.updateRef(ref, entry.getChangeType(ref), entry.getOldId(ref), entry.getNewId(ref));
        refPush.addCommits(entry.getCommits(ref));
        refMap.get(ref).add(refPush);
      }
    }

    // merge individual ref entries into master list
View Full Code Here

                                if (!tags.containsKey(dateStr)) {
                              UserModel tagUser = newUserModelFrom(ref.getAuthorIdent());
                              Date tagDate = commit.getAuthorIdent().getWhen();
                              tags.put(dateStr, new DailyLogEntry(repositoryName, tagDate, tagUser));
                                }
                                RefLogEntry tagEntry = tags.get(dateStr);
                                tagEntry.updateRef(ref.getName(), ReceiveCommand.Type.CREATE);
                                RepositoryCommit rc = repoCommit.clone(ref.getName());
                                tagEntry.addCommit(rc);
                            } else if (ref.getName().startsWith(Constants.R_PULL)) {
                                // treat pull requests as special events in the log
                                if (!pulls.containsKey(dateStr)) {
                              UserModel commitUser = newUserModelFrom(ref.getAuthorIdent());
                              Date commitDate = commit.getAuthorIdent().getWhen();
                              pulls.put(dateStr, new DailyLogEntry(repositoryName, commitDate, commitUser));
                                }
                                RefLogEntry pullEntry = pulls.get(dateStr);
                                pullEntry.updateRef(ref.getName(), ReceiveCommand.Type.CREATE);
                                RepositoryCommit rc = repoCommit.clone(ref.getName());
                                pullEntry.addCommit(rc);
                            }
                        }
                    }
                }
            }
View Full Code Here

      }

      UserModel user = newUserModelFrom(push.getAuthorIdent());
      Date date = push.getAuthorIdent().getWhen();

      RefLogEntry log = new RefLogEntry(repositoryName, date, user);

      // only report HEADS and TAGS for now
      List<PathChangeModel> changedRefs = new ArrayList<PathChangeModel>();
      for (PathChangeModel refChange : JGitUtils.getFilesInCommit(repository, push)) {
        if (refChange.path.startsWith(Constants.R_HEADS)
            || refChange.path.startsWith(Constants.R_TAGS)) {
          changedRefs.add(refChange);
        }
      }
      if (changedRefs.isEmpty()) {
        // skip empty commits
        continue;
      }
      list.add(log);
      for (PathChangeModel change : changedRefs) {
        switch (change.changeType) {
        case DELETE:
          log.updateRef(change.path, ReceiveCommand.Type.DELETE);
          break;
        default:
          String content = JGitUtils.getStringContent(repository, push.getTree(), change.path);
          String [] fields = content.split(" ");
          String oldId = fields[1];
          String newId = fields[2];
          log.updateRef(change.path, ReceiveCommand.Type.valueOf(fields[0]), oldId, newId);
          if (ObjectId.zeroId().getName().equals(newId)) {
            // ref deletion
            continue;
          }
          try {
            List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId);
            for (RevCommit pushedCommit : pushedCommits) {
              RepositoryCommit repoCommit = log.addCommit(change.path, pushedCommit);
              if (repoCommit != null) {
                repoCommit.setRefs(allRefs.get(pushedCommit.getId()));
              }
            }
          } catch (Exception e) {
View Full Code Here

    DataView<RefLogEntry> changeView = new DataView<RefLogEntry>("change", dp) {
      private static final long serialVersionUID = 1L;

      @Override
      public void populateItem(final Item<RefLogEntry> changeItem) {
        final RefLogEntry change = changeItem.getModelObject();

        String dateFormat = app().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy HH:mm Z");
        TimeZone timezone = getTimeZone();
        DateFormat df = new SimpleDateFormat(dateFormat);
        df.setTimeZone(timezone);
        Calendar cal = Calendar.getInstance(timezone);

        String fullRefName = change.getChangedRefs().get(0);
        String shortRefName = fullRefName;
        String ticketId = null;
        boolean isTag = false;
        boolean isTicket = false;
        if (shortRefName.startsWith(Constants.R_TICKET)) {
          ticketId = fullRefName.substring(Constants.R_TICKET.length());
          shortRefName = MessageFormat.format(getString("gb.ticketN"), ticketId);
          isTicket = true;
        } else if (shortRefName.startsWith(Constants.R_HEADS)) {
          shortRefName = shortRefName.substring(Constants.R_HEADS.length());
        } else if (shortRefName.startsWith(Constants.R_TAGS)) {
          shortRefName = shortRefName.substring(Constants.R_TAGS.length());
          isTag = true;
        }

        String fuzzydate;
        TimeUtils tu = getTimeUtils();
        Date changeDate = change.date;
        if (TimeUtils.isToday(changeDate, timezone)) {
          fuzzydate = tu.today();
        } else if (TimeUtils.isYesterday(changeDate, timezone)) {
          fuzzydate = tu.yesterday();
        } else {
          // calculate a fuzzy time ago date
                  cal.setTime(changeDate);
                  cal.set(Calendar.HOUR_OF_DAY, 0);
                  cal.set(Calendar.MINUTE, 0);
                  cal.set(Calendar.SECOND, 0);
                  cal.set(Calendar.MILLISECOND, 0);
                  Date date = cal.getTime();
          fuzzydate = getTimeUtils().timeAgo(date);
        }
        changeItem.add(new Label("whenChanged", fuzzydate + ", " + df.format(changeDate)));

        Label changeIcon = new Label("changeIcon");
        if (Type.DELETE.equals(change.getChangeType(fullRefName))) {
          WicketUtils.setCssClass(changeIcon, "iconic-trash-stroke");
        } else if (isTag) {
          WicketUtils.setCssClass(changeIcon, "iconic-tag");
        } else if (isTicket) {
          WicketUtils.setCssClass(changeIcon, "fa fa-ticket");
        } else {
          WicketUtils.setCssClass(changeIcon, "iconic-upload");
        }
        changeItem.add(changeIcon);

        if (change.user.username.equals(change.user.emailAddress) && change.user.emailAddress.indexOf('@') > -1) {
          // username is an email address - 1.2.1 push log bug
          changeItem.add(new Label("whoChanged", change.user.getDisplayName()));
        } else if (change.user.username.equals(UserModel.ANONYMOUS.username)) {
          // anonymous change
          changeItem.add(new Label("whoChanged", getString("gb.anonymousUser")));
        } else {
          // link to user account page
          changeItem.add(new LinkPanel("whoChanged", null, change.user.getDisplayName(),
              UserPage.class, WicketUtils.newUsernameParameter(change.user.username)));
        }

        boolean isDelete = false;
        boolean isRewind = false;
        String what;
        String by = null;
        switch(change.getChangeType(fullRefName)) {
        case CREATE:
          if (isTag) {
            // new tag
            what = getString("gb.pushedNewTag");
          } else {
            // new branch
            what = getString("gb.pushedNewBranch");
          }
          break;
        case DELETE:
          isDelete = true;
          if (isTag) {
            what = getString("gb.deletedTag");
          } else {
            what = getString("gb.deletedBranch");
          }
          break;
        case UPDATE_NONFASTFORWARD:
          isRewind = true;
        default:
          what = MessageFormat.format(change.getCommitCount() > 1 ? getString("gb.pushedNCommitsTo") : getString("gb.pushedOneCommitTo"), change.getCommitCount());

          if (change.getAuthorCount() == 1) {
            by = MessageFormat.format(getString("gb.byOneAuthor"), change.getAuthorIdent().getName());
          } else {
            by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
          }
          break;
        }
        changeItem.add(new Label("whatChanged", what));
        changeItem.add(new Label("byAuthors", by).setVisible(!StringUtils.isEmpty(by)));
        changeItem.add(new Label("refRewind", getString("gb.rewind")).setVisible(isRewind));

        if (isDelete) {
          // can't link to deleted ref
          changeItem.add(new Label("refChanged", shortRefName));
        } else if (isTag) {
          // link to tag
          changeItem.add(new LinkPanel("refChanged", null, shortRefName,
              TagPage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
        } else if (isTicket) {
          // link to ticket
          changeItem.add(new LinkPanel("refChanged", null, shortRefName,
              TicketsPage.class, WicketUtils.newObjectParameter(change.repository, ticketId)));
        } else {
          // link to tree
          changeItem.add(new LinkPanel("refChanged", null, shortRefName,
            TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
        }

        int maxCommitCount = 5;
        List<RepositoryCommit> commits = change.getCommits();
        if (commits.size() > maxCommitCount) {
          commits = new ArrayList<RepositoryCommit>(commits.subList(0,  maxCommitCount));
        }

        // compare link
        String compareLinkText = null;
        if ((change.getCommitCount() <= maxCommitCount) && (change.getCommitCount() > 1)) {
          compareLinkText = MessageFormat.format(getString("gb.viewComparison"), commits.size());
        } else if (change.getCommitCount() > maxCommitCount) {
          int diff = change.getCommitCount() - maxCommitCount;
          compareLinkText = MessageFormat.format(diff > 1 ? getString("gb.nMoreCommits") : getString("gb.oneMoreCommit"), diff);
        }
        if (StringUtils.isEmpty(compareLinkText)) {
          changeItem.add(new Label("compareLink").setVisible(false));
        } else {
          String endRangeId = change.getNewId(fullRefName);
          String startRangeId = change.getOldId(fullRefName);
          changeItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));
        }

        ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
        DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
View Full Code Here

TOP

Related Classes of com.gitblit.models.RefLogEntry

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.