| | |
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.lib.StoredConfig;
|
| | | import org.eclipse.jgit.transport.FetchResult;
|
| | | import org.eclipse.jgit.transport.ReceiveCommand;
|
| | | import org.eclipse.jgit.transport.ReceiveCommand.Type;
|
| | | import org.eclipse.jgit.transport.RemoteConfig;
|
| | | import org.eclipse.jgit.transport.TrackingRefUpdate;
|
| | | import org.slf4j.Logger;
|
| | |
| | |
|
| | | import com.gitblit.IStoredSettings;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.git.ReceiveCommandEvent;
|
| | | import com.gitblit.manager.IRepositoryManager;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.tickets.BranchTicketService;
|
| | | import com.gitblit.tickets.BranchTicketService.TicketsBranchUpdated;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | |
|
| | | /**
|
| | |
| | | FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call();
|
| | | Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
|
| | | if (refUpdates.size() > 0) {
|
| | | boolean ticketBranchUpdated = false;
|
| | | ReceiveCommand ticketBranchCmd = null;
|
| | | for (TrackingRefUpdate ru : refUpdates) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | sb.append("updated mirror ");
|
| | |
| | | logger.info(sb.toString());
|
| | |
|
| | | if (BranchTicketService.BRANCH.equals(ru.getLocalName())) {
|
| | | ticketBranchUpdated = true;
|
| | | ReceiveCommand.Type type = null;
|
| | | switch (ru.getResult()) {
|
| | | case NEW:
|
| | | type = Type.CREATE;
|
| | | break;
|
| | | case FAST_FORWARD:
|
| | | type = Type.UPDATE;
|
| | | break;
|
| | | case FORCED:
|
| | | type = Type.UPDATE_NONFASTFORWARD;
|
| | | break;
|
| | | default:
|
| | | type = null;
|
| | | break;
|
| | | }
|
| | |
|
| | | if (type != null) {
|
| | | ticketBranchCmd = new ReceiveCommand(ru.getOldObjectId(),
|
| | | ru.getNewObjectId(), ru.getLocalName(), type);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (ticketBranchUpdated) {
|
| | | repository.fireEvent(new TicketsBranchUpdated(model));
|
| | | if (ticketBranchCmd != null) {
|
| | | repository.fireEvent(new ReceiveCommandEvent(model, ticketBranchCmd));
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|