ReceiveCommand receiveCommand = trackingRefUpdate.asReceiveCommand(); if (receiveCommand.getType() == DELETE) { String localRefName = trackingRefUpdate.getLocalName(); if (StringUtils.startsWithIgnoreCase(localRefName, LOCAL_BRANCH_REF_PREFIX)) { String localBranchName = localRefName.substring(LOCAL_BRANCH_REF_PREFIX.length(), localRefName.length());
/** * Create a new instance of this object basing on existing instance for * configuration. State (like {@link #getMessage()}, {@link #getStatus()}) * of base object is not shared. Expected old object id is set up from * scratch, as this constructor may be used for 2-stage push: first one * being dry run, second one being actual push. * * @param base * configuration base. * @param newExpectedOldObjectId * new expected object id value. * @throws java.io.IOException * when I/O error occurred during creating * {@link org.eclipse.jgit.transport.TrackingRefUpdate} for * local tracking branch or srcRef of base object no longer can * be resolved to any object. */ public RemoteRefUpdate(final RemoteRefUpdate base, final ObjectId newExpectedOldObjectId) throws IOException { this(base.localDb, base.srcRef, base.remoteName, base.forceUpdate, (base.trackingRefUpdate == null ? null : base.trackingRefUpdate .getLocalName()), newExpectedOldObjectId); }
void add(TrackingRefUpdate u) { updates.put(u.getLocalName(), u); }
private void addUpdateBatchCommands(FetchResult result, BatchRefUpdate batch) throws TransportException { Map<String, ObjectId> refs = new HashMap<>(); for (TrackingRefUpdate u : localUpdates) { // Try to skip duplicates if they'd update to the same object ID ObjectId existing = refs.get(u.getLocalName()); if (existing == null) { refs.put(u.getLocalName(), u.getNewObjectId()); result.add(u); batch.addCommand(u.asReceiveCommand()); } else if (!existing.equals(u.getNewObjectId())) { throw new TransportException(MessageFormat .format(JGitText.get().duplicateRef, u.getLocalName())); } } }
/** * Create a new instance of this object basing on existing instance for * configuration. State (like {@link #getMessage()}, {@link #getStatus()}) * of base object is not shared. Expected old object id is set up from * scratch, as this constructor may be used for 2-stage push: first one * being dry run, second one being actual push. * * @param base * configuration base. * @param newExpectedOldObjectId * new expected object id value. * @throws IOException * when I/O error occurred during creating * {@link TrackingRefUpdate} for local tracking branch or srcRef * of base object no longer can be resolved to any object. */ public RemoteRefUpdate(final RemoteRefUpdate base, final ObjectId newExpectedOldObjectId) throws IOException { this(base.localDb, base.srcRef, base.remoteName, base.forceUpdate, (base.trackingRefUpdate == null ? null : base.trackingRefUpdate .getLocalName()), newExpectedOldObjectId); }
/** * Create a new instance of this object basing on existing instance for * configuration. State (like {@link #getMessage()}, {@link #getStatus()}) * of base object is not shared. Expected old object id is set up from * scratch, as this constructor may be used for 2-stage push: first one * being dry run, second one being actual push. * * @param base * configuration base. * @param newExpectedOldObjectId * new expected object id value. * @throws java.io.IOException * when I/O error occurred during creating * {@link org.eclipse.jgit.transport.TrackingRefUpdate} for * local tracking branch or srcRef of base object no longer can * be resolved to any object. */ public RemoteRefUpdate(final RemoteRefUpdate base, final ObjectId newExpectedOldObjectId) throws IOException { this(base.localDb, base.srcRef, base.remoteName, base.forceUpdate, (base.trackingRefUpdate == null ? null : base.trackingRefUpdate .getLocalName()), newExpectedOldObjectId); }
void add(final TrackingRefUpdate u) { updates.put(u.getLocalName(), u); }
void add(TrackingRefUpdate u) { updates.put(u.getLocalName(), u); }
private void addUpdateBatchCommands(FetchResult result, BatchRefUpdate batch) throws TransportException { Map<String, ObjectId> refs = new HashMap<>(); for (TrackingRefUpdate u : localUpdates) { // Try to skip duplicates if they'd update to the same object ID ObjectId existing = refs.get(u.getLocalName()); if (existing == null) { refs.put(u.getLocalName(), u.getNewObjectId()); result.add(u); batch.addCommand(u.asReceiveCommand()); } else if (!existing.equals(u.getNewObjectId())) { throw new TransportException(MessageFormat .format(JGitText.get().duplicateRef, u.getLocalName())); } } }
private List<TrackingRefUpdate> fetch(Repository repository) throws Exception { logger.info("Fetching changes of repository {}", repository.getDirectory().toString()); try (Git git = new Git(repository)) { FetchResult result = git.fetch().call(); Collection<TrackingRefUpdate> updates = result.getTrackingRefUpdates(); List<TrackingRefUpdate> remoteRefsChanges = new ArrayList<TrackingRefUpdate>(); for (TrackingRefUpdate update : updates) { String refName = update.getLocalName(); if (refName.startsWith(REMOTE_REFS_PREFIX)) { ObjectId newObjectId = update.getNewObjectId(); logger.info("{} is now at {}", refName, newObjectId.getName()); remoteRefsChanges.add(update); } } if (updates.isEmpty()) { logger.info("Nothing changed"); } return remoteRefsChanges; } }
if (update.getRemoteName().startsWith(Constants.R_HEADS)) return UIIcons.BRANCH; if (update.getLocalName().startsWith(Constants.R_TAGS)) return UIIcons.TAG; if (update.getLocalName().startsWith(Constants.R_NOTES)) return UIIcons.NOTE; break; if (update.getRemoteName().startsWith(Constants.R_HEADS)) return UIIcons.CREATE_BRANCH; if (update.getLocalName().startsWith(Constants.R_TAGS)) return UIIcons.CREATE_TAG; if (update.getLocalName().startsWith(Constants.R_NOTES)) return UIIcons.NOTE; break;
private List<TrackingRefUpdate> fetch(Repository repository) throws Exception { logger.info("Fetching changes of repository {}", repository.getDirectory().toString()); try (Git git = new Git(repository)) { FetchResult result = git.fetch().call(); Collection<TrackingRefUpdate> updates = result.getTrackingRefUpdates(); List<TrackingRefUpdate> remoteRefsChanges = new ArrayList<TrackingRefUpdate>(); for (TrackingRefUpdate update : updates) { String refName = update.getLocalName(); if (refName.startsWith(REMOTE_REFS_PREFIX)) { ObjectId newObjectId = update.getNewObjectId(); logger.info("{} is now at {}", refName, newObjectId.getName()); remoteRefsChanges.add(update); } } if (updates.isEmpty()) { logger.info("Nothing changed"); } return remoteRefsChanges; } }
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception { List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>(); for (Ref ref : repository.getAllRefs().values()) { String refName = ref.getName(); if (refName.startsWith(REMOTE_REFS_PREFIX)) { currentRemoteRefs.add(ref.getObjectId()); } } List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository); RevWalk walk = new RevWalk(repository); for (TrackingRefUpdate newRef : newRemoteRefs) { if (branch == null || newRef.getLocalName().endsWith("/" + branch)) { walk.markStart(walk.parseCommit(newRef.getNewObjectId())); } } for (ObjectId oldRef : currentRemoteRefs) { walk.markUninteresting(walk.parseCommit(oldRef)); } walk.setRevFilter(commitsFilter); return walk; }
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception { List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>(); for (Ref ref : repository.getAllRefs().values()) { String refName = ref.getName(); if (refName.startsWith(REMOTE_REFS_PREFIX)) { currentRemoteRefs.add(ref.getObjectId()); } } List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository); RevWalk walk = new RevWalk(repository); for (TrackingRefUpdate newRef : newRemoteRefs) { if (branch == null || newRef.getLocalName().endsWith("/" + branch)) { walk.markStart(walk.parseCommit(newRef.getNewObjectId())); } } for (ObjectId oldRef : currentRemoteRefs) { walk.markUninteresting(walk.parseCommit(oldRef)); } walk.setRevFilter(commitsFilter); return walk; }
if (GitUtil.isHead(tru.getLocalName()))
if (u.getRemoteName().startsWith(Constants.R_HEADS)) return "[new branch]"; else if (u.getLocalName().startsWith(Constants.R_TAGS)) return "[new tag]"; return "[new]";
protected void showFetchResult(final FetchResult r) throws IOException { ObjectReader reader = db.newObjectReader(); try { boolean shownURI = false; for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) { if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE) continue; final char type = shortTypeOf(u.getResult()); final String longType = longTypeOf(reader, u); final String src = abbreviateRef(u.getRemoteName(), false); final String dst = abbreviateRef(u.getLocalName(), true); if (!shownURI) { outw.println(MessageFormat.format(CLIText.get().fromURI, r.getURI())); shownURI = true; } outw.format(" %c %-17s %-10s -> %s", valueOf(type), longType, //$NON-NLS-1$ src, dst); outw.println(); } } finally { reader.release(); } showRemoteMessages(errw, r.getMessages()); }
public StyledString getStyledText(Object object) { StyledString styled = new StyledString(); final String remote = update.getRemoteName(); final String local = update.getLocalName(); styled.append(shortenRef(remote)); styled.append(" : ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$