Java Code Examples for org.eclipse.jgit.transport.FetchResult#getAdvertisedRef()
The following examples show how to use
org.eclipse.jgit.transport.FetchResult#getAdvertisedRef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StudioNodeSyncGlobalRepoTask.java From studio with GNU General Public License v3.0 | 6 votes |
private void updateBranch(Git git, ClusterMember remoteNode) throws CryptoException, GitAPIException, IOException, ServiceLayerException { final Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp"); FetchCommand fetchCommand = git.fetch().setRemote(remoteNode.getGitRemoteName()); fetchCommand = configureAuthenticationForCommand(remoteNode, fetchCommand, tempKey); FetchResult fetchResult = fetchCommand.call(); ObjectId commitToMerge; Ref r; if (fetchResult != null) { r = fetchResult.getAdvertisedRef(Constants.MASTER); if (r == null) { r = fetchResult.getAdvertisedRef(Constants.R_HEADS + Constants.MASTER); } if (r != null) { commitToMerge = r.getObjectId(); MergeCommand mergeCommand = git.merge(); mergeCommand.setMessage(studioConfiguration.getProperty(REPO_SYNC_DB_COMMIT_MESSAGE_NO_PROCESSING)); mergeCommand.setCommit(true); mergeCommand.include(remoteNode.getGitRemoteName(), commitToMerge); mergeCommand.setStrategy(MergeStrategy.THEIRS); mergeCommand.call(); } } Files.delete(tempKey); }
Example 2
Source File: StudioNodeSyncSandboxTask.java From studio with GNU General Public License v3.0 | 5 votes |
private void updateBranch(Git git, ClusterMember remoteNode) throws CryptoException, GitAPIException, IOException, ServiceLayerException { final Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp"); FetchCommand fetchCommand = git.fetch().setRemote(remoteNode.getGitRemoteName()); fetchCommand = configureAuthenticationForCommand(remoteNode, fetchCommand, tempKey); FetchResult fetchResult = fetchCommand.call(); ObjectId commitToMerge; Ref r; if (fetchResult != null) { r = fetchResult.getAdvertisedRef(REPO_SANDBOX_BRANCH); if (r == null) { r = fetchResult.getAdvertisedRef(Constants.R_HEADS + studioConfiguration.getProperty(REPO_SANDBOX_BRANCH)); } if (r != null) { commitToMerge = r.getObjectId(); MergeCommand mergeCommand = git.merge(); mergeCommand.setMessage(studioConfiguration.getProperty(REPO_SYNC_DB_COMMIT_MESSAGE_NO_PROCESSING)); mergeCommand.setCommit(true); mergeCommand.include(remoteNode.getGitRemoteName(), commitToMerge); mergeCommand.setStrategy(MergeStrategy.THEIRS); MergeResult result = mergeCommand.call(); if (result.getMergeStatus().isSuccessful()) { deploymentService.syncAllContentToPreview(siteId, true); } } } Files.delete(tempKey); }
Example 3
Source File: StudioNodeSyncPublishedTask.java From studio with GNU General Public License v3.0 | 4 votes |
private void updatePublishedBranch(Git git, ClusterMember remoteNode, String branch) throws CryptoException, GitAPIException, IOException, ServiceLayerException { logger.debug("Update published environment " + branch + " from " + remoteNode.getLocalAddress() + " for site " + siteId); final Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp"); Repository repo = git.getRepository(); Ref ref = repo.exactRef(Constants.R_HEADS + branch); boolean createBranch = (ref == null); logger.debug("Checkout " + branch); CheckoutCommand checkoutCommand = git.checkout() .setName(branch) .setCreateBranch(createBranch); if (createBranch) { checkoutCommand.setStartPoint(remoteNode.getGitRemoteName() + "/" + branch); } checkoutCommand.call(); FetchCommand fetchCommand = git.fetch().setRemote(remoteNode.getGitRemoteName()); fetchCommand = configureAuthenticationForCommand(remoteNode, fetchCommand, tempKey); FetchResult fetchResult = fetchCommand.call(); ObjectId commitToMerge; Ref r; if (fetchResult != null) { r = fetchResult.getAdvertisedRef(branch); if (r == null) { r = fetchResult.getAdvertisedRef(Constants.R_HEADS + branch); } if (r != null) { commitToMerge = r.getObjectId(); MergeCommand mergeCommand = git.merge(); mergeCommand.setMessage(studioConfiguration.getProperty(REPO_SYNC_DB_COMMIT_MESSAGE_NO_PROCESSING)); mergeCommand.setCommit(true); mergeCommand.include(remoteNode.getGitRemoteName(), commitToMerge); mergeCommand.setStrategy(MergeStrategy.THEIRS); mergeCommand.call(); } } Files.delete(tempKey); }