Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RefSpec


        requireLocalBranchExists(prefixedReleaseName);
        requireCleanWorkingTree();

        if (fetch)
        {
            RefSpec developSpec = new RefSpec("+" + Constants.R_HEADS + gfConfig.getDevelop() + ":" + Constants.R_REMOTES + "origin/" + gfConfig.getDevelop());
            RefSpec masterSpec = new RefSpec("+" + Constants.R_HEADS + gfConfig.getMaster() + ":" + Constants.R_REMOTES + "origin/" + gfConfig.getMaster());

            git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(masterSpec).call();
            git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(developSpec).call();
            git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).call();
        }

        if (GitHelper.remoteBranchExists(git, gfConfig.getMaster()))
        {
            requireLocalBranchNotBehindRemote(gfConfig.getMaster());
        }

        if (GitHelper.remoteBranchExists(git, gfConfig.getDevelop()))
        {
            requireLocalBranchNotBehindRemote(gfConfig.getDevelop());
        }

        Ref releaseBranch = GitHelper.getLocalBranch(git, prefixedReleaseName);
        RevCommit releaseCommit = GitHelper.getLatestCommit(git,prefixedReleaseName);
       
        /*
        try to merge into master
        in case a previous attempt to finish this release branch has failed,
        but the merge into master was successful, we skip it now
         */
        if (!GitHelper.isMergedInto(git, prefixedReleaseName, gfConfig.getMaster()))
        {
            git.checkout().setName(gfConfig.getMaster()).call();

            MergeResult masterResult = null;

            if (squash)
            {
                masterResult = git.merge().setSquash(true).include(releaseBranch).call();
                git.commit().call();
            }
            else
            {
                masterResult = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(releaseBranch).call();
            }
        }

        if (!noTag)
        {
            /*
            try to tag the release
            in case a previous attempt to finish this release branch has failed,
            but the tag was successful, we skip it now
            */
            String tagName = gfConfig.getPrefixValue(JGitFlowConstants.PREFIXES.VERSIONTAG.configKey()) + releaseName;
            if(!GitHelper.tagExists(git,tagName))
            {
                git.tag().setName(tagName).setMessage(message).setObjectId(releaseCommit).call();
            }
        }
       
        /*
        try to merge into develop
        in case a previous attempt to finish this release branch has failed,
        but the merge into develop was successful, we skip it now
         */
        if (!GitHelper.isMergedInto(git, prefixedReleaseName, gfConfig.getDevelop()))
        {
            git.checkout().setName(gfConfig.getDevelop()).call();

            MergeResult developResult = null;

            if (squash)
            {
                developResult = git.merge().setSquash(true).include(releaseBranch).call();
                git.commit().call();
            }
            else
            {
                developResult = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(releaseBranch).call();
            }
        }
       
        if(!keepBranch)
        {
            //make sure we're on master
            git.checkout().setName(gfConfig.getMaster()).call();
            git.branchDelete().setForce(true).setBranchNames(prefixedReleaseName).call();
        }
       
        if(push)
        {
            //push to develop
            RefSpec developSpec = new RefSpec(gfConfig.getDevelop());
            git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(developSpec).call();
           
            //push to master
            RefSpec masterSpec = new RefSpec(gfConfig.getMaster());
            git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(masterSpec).call();
           
            if(!noTag)
            {
                git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setPushTags().call();
            }

            if (GitHelper.remoteBranchExists(git, prefixedReleaseName))
            {
                RefSpec branchSpec = new RefSpec(prefixedReleaseName);
                git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(branchSpec).call();
            }
        }

        git.checkout().setName(gfConfig.getDevelop()).call();
View Full Code Here


        try
        {
            //update from remote if needed
            if (remoteFeatureExists && fetchDevelop)
            {
                RefSpec branchSpec = new RefSpec("+" + Constants.R_HEADS + prefixedBranchName + ":" + Constants.R_REMOTES + "origin/" + prefixedBranchName);
                RefSpec developSpec = new RefSpec("+" + Constants.R_HEADS + gfConfig.getDevelop() + ":" + Constants.R_REMOTES + "origin/" + gfConfig.getDevelop());
                git.fetch().setRefSpecs(branchSpec).call();
                git.fetch().setRefSpecs(developSpec).call();
            }

            //make sure nothing is behind
            if (remoteFeatureExists)
            {
                requireLocalBranchNotBehindRemote(prefixedBranchName);
            }

            if (GitHelper.remoteBranchExists(git, gfConfig.getDevelop()))
            {
                requireLocalBranchNotBehindRemote(gfConfig.getDevelop());
            }

            if (rebase)
            {
                FeatureRebaseCommand rebaseCommand = new FeatureRebaseCommand(branchName, git, gfConfig, reporter);
                rebaseCommand.setAllowUntracked(isAllowUntracked()).call();
            }

            if(!noMerge)
            {
                //merge into base
                git.checkout().setName(gfConfig.getDevelop()).call();
   
                Ref featureBranch = GitHelper.getLocalBranch(git, prefixedBranchName);
   
                RevCommit developCommit = GitHelper.getLatestCommit(git, gfConfig.getDevelop());
                RevCommit featureCommit = GitHelper.getLatestCommit(git, prefixedBranchName);
   
                List<RevCommit> commitList = IterableHelper.asList(git.log().setMaxCount(2).addRange(developCommit, featureCommit).call());
   
                MergeResult mergeResult = null;
   
                if (commitList.size() < 2)
                {
                    mergeResult = git.merge().setFastForward(MergeCommand.FastForwardMode.FF).include(featureBranch).call();
                    if(mergeResult.getMergeStatus().isSuccessful())
                    {
                        git.commit().setMessage("merging " + prefixedBranchName + "' into develop").call();
                    }
                }
                else
                {
                    if (squash)
                    {
                        mergeResult = git.merge().setSquash(true).include(featureBranch).call();
                        if(mergeResult.getMergeStatus().isSuccessful())
                        {
                            git.commit().setMessage("squashing " + prefixedBranchName + "' into develop").call();
                        }
                        this.forceDeleteBranch = true;
                    }
                    else
                    {
                        mergeResult = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(featureBranch).call();
                        if(mergeResult.getMergeStatus().isSuccessful())
                        {
                            git.commit().setMessage("merging " + prefixedBranchName + "' into develop").call();
                        }
                    }
                }
   
                if (null == mergeResult || mergeResult.getMergeStatus().equals(MergeResult.MergeStatus.FAILED) || mergeResult.getMergeStatus().equals(MergeResult.MergeStatus.CONFLICTING))
                {
                    FileHelper.createParentDirs(mergeBase);
                    FileUtils.createNewFile(mergeBase);
                    FileHelper.writeStringToFile(gfConfig.getDevelop(), mergeBase);
                    reporter.endCommand();
                    throw new MergeConflictsNotResolvedException("merge conflicts exist, please resolve!");
                }
            }

            if (push)
            {
                if (GitHelper.remoteBranchExists(git, prefixedBranchName))
                {
                    reporter.infoText(getCommandName(), "pushing feature branch");
                    RefSpec branchSpec = new RefSpec(prefixedBranchName);
                    git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(branchSpec).call();
                }
            }
           
            cleanupBranch(prefixedBranchName);
View Full Code Here

            git.checkout().setName(gfConfig.getDevelop()).call();

            //delete the branch
            if (fetchDevelop)
            {
                RefSpec spec = new RefSpec(":" + Constants.R_HEADS + branch);
                git.push().setRemote("origin").setRefSpecs(spec).call();
            }

            if (!keepBranch)
            {
View Full Code Here

                updateFeaturePomsWithFeatureVersion(featureName, flow, ctx, reactorProjects, session);
               
                if(ctx.isPushFeatures())
                {
                    projectHelper.ensureOrigin(reactorProjects, flow);
                    RefSpec branchSpec = new RefSpec(prefixedBranchName);
                    flow.git().push().setRemote("origin").setRefSpecs(branchSpec).call();
                }
            }

            projectHelper.commitAllPoms(flow.git(), reactorProjects, "updating poms for " + featureName + " branch");
View Full Code Here

  private void saveRemote(final URIish uri) throws URISyntaxException,
      IOException {
    final StoredConfig dstcfg = dst.getConfig();
    final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName);
    rc.addURI(uri);
    rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
        .setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$
            Constants.R_REMOTES + remoteName + "/*")); //$NON-NLS-1$
    rc.update(dstcfg);
    dstcfg.save();
  }
View Full Code Here

      if (! silentUpload)
        cmd.setProgressMonitor(new TextProgressMonitor());

      Iterable<PushResult> pushResults = null;
      try {
        pushResults = cmd.setRefSpecs(new RefSpec("HEAD:refs/heads/master")).//
            setForce(true).//
            setRemote(remote).//
            call();
      } catch (Exception exc) {
        // Ignore
View Full Code Here

            mergeOptions = new PreBuildMergeOptions();

            recursiveSubmodules = false;

            remoteRepositories.add(
                newRemoteConfig("origin", source, new RefSpec("+refs/heads/*:refs/remotes/origin/*"),StringUtils.EMPTY));
            if (branch != null) {
                branches.add(new BranchSpec(branch));
            } else {
                branches.add(new BranchSpec(DEFAULT_BRANCH));
            }
View Full Code Here

        List<RemoteConfig> expandedRepos = new ArrayList<RemoteConfig>();

        for (RemoteConfig oldRepo : Util.fixNull(remoteRepositories)) {
            expandedRepos.add(newRemoteConfig(oldRepo.getName(),
                oldRepo.getURIs().get(0).toPrivateString(),
                new RefSpec(getRefSpec(oldRepo, build)),
                getRemoteConfigTargetDir(oldRepo)));
        }

        return expandedRepos;
    }
View Full Code Here

            }

            if (ctx.isPushFeatures())
            {
                final String prefixedBranchName = flow.getFeatureBranchPrefix() + featureName;
                RefSpec branchSpec = new RefSpec(prefixedBranchName);
                flow.git().push().setRemote("origin").setRefSpecs(branchSpec).call();
            }
        }
        catch (GitAPIException e)
        {
View Full Code Here

            updateHotfixPomsWithSnapshot(hotfixLabel, flow, ctx, config, originalProjects, session);

            if(ctx.isPushHotfixes())
            {
                final String prefixedBranchName = flow.getHotfixBranchPrefix() + hotfixLabel;
                RefSpec branchSpec = new RefSpec(prefixedBranchName);
                flow.git().push().setRemote("origin").setRefSpecs(branchSpec).call();
            }
        }
        catch (JGitFlowException e)
        {
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.RefSpec

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.