Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.RefSpec


        MergeResult masterResult = new MergeResult(null,null,new ObjectId[] { null, null }, MergeResult.MergeStatus.ALREADY_UP_TO_DATE,MergeStrategy.RESOLVE,null);
        try
        {
            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 hotfixBranch = GitHelper.getLocalBranch(git, prefixedHotfixName);
            RevCommit hotfixCommit = GitHelper.getLatestCommit(git, prefixedHotfixName);
       
        /*
        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, prefixedHotfixName, gfConfig.getMaster()))
            {
                git.checkout().setName(gfConfig.getMaster()).call();

                masterResult = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(hotfixBranch).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()) + hotfixName;
                if (!GitHelper.tagExists(git, tagName))
                {
                    git.tag().setName(tagName).setMessage(message).setObjectId(hotfixCommit).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, prefixedHotfixName, gfConfig.getDevelop()))
            {
                git.checkout().setName(gfConfig.getDevelop()).call();

                developResult = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(hotfixBranch).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, prefixedHotfixName))
                {
                    RefSpec branchSpec = new RefSpec(prefixedHotfixName);
                    git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(branchSpec).call();
                }
            }

            if (!keepBranch)
            {
                git.checkout().setName(gfConfig.getDevelop()).call();
                git.branchDelete().setForce(true).setBranchNames(prefixedHotfixName).call();

                if (push && GitHelper.remoteBranchExists(git, prefixedHotfixName))
                {
                    RefSpec deleteSpec = new RefSpec(":" + Constants.R_HEADS + prefixedHotfixName);
                    git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(deleteSpec).call();
                }
            }

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


        requireGitFlowInitialized();
        requireLocalBranchAbsent(prefixedBranchName);
       
        if(fetchDevelop)
        {
            RefSpec spec = new RefSpec("+" + Constants.R_HEADS + gfConfig.getDevelop() + ":" + Constants.R_REMOTES + "origin/" + gfConfig.getDevelop());
            try
            {
                FetchResult result = git.fetch().setRefSpecs(spec).call();
            }
            catch (GitAPIException e)
View Full Code Here

    // create the remote config and save it
    RemoteConfig config = new RemoteConfig(repo.getConfig(), remote);
    config.addURI(u);

    final String dst = Constants.R_REMOTES + config.getName();
    RefSpec refSpec = new RefSpec();
    refSpec = refSpec.setForceUpdate(true);
    refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$

    config.addFetchRefSpec(refSpec);
    config.update(repo.getConfig());
    repo.getConfig().save();

View Full Code Here

            Ref tagRef = git.tag().setName( escapedTagName ).setMessage( tagMessage ).setForceUpdate( false ).call();

            if ( repo.isPushChanges() )
            {
                getLogger().info( "push tag [" + escapedTagName + "] to remote..." );
                JGitUtils.push( getLogger(), git, (GitScmProviderRepository) repo, new RefSpec( Constants.R_TAGS
                    + escapedTagName ) );
            }

            // search for the tagged files
            RevWalk revWalk = new RevWalk( git.getRepository() );
View Full Code Here

            }

            if ( repo.isPushChanges() )
            {
                getLogger().info( "push branch [" + branch + "] to remote..." );
                JGitUtils.push( getLogger(), git, (GitScmProviderRepository) repo, new RefSpec( Constants.R_HEADS
                    + branch ) );
            }

            // search for the tagged files
            final RevWalk revWalk = new RevWalk( git.getRepository() );
View Full Code Here

                String branch = version != null ? version.getName() : null;
                if ( StringUtils.isBlank( branch ) )
                {
                    branch = git.getRepository().getBranch();
                }
                RefSpec refSpec = new RefSpec( Constants.R_HEADS + branch + ":" + Constants.R_HEADS + branch );
                getLogger().info( "push changes to remote... " + refSpec.toString() );
                JGitUtils.push( getLogger(), git, (GitScmProviderRepository) repo, refSpec );
            }

            return new CheckInScmResult( "JGit checkin", checkedInFiles );
        }
View Full Code Here

      clone.setDirectory(folder);
      Git git = clone.call();

      // fetch tags
      FetchCommand fetch  = git.fetch();
      fetch.setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"));
      fetch.call();

      git.getRepository().close();
    } catch (Exception e) {
      throw new GitBlitException(e);
View Full Code Here

      Repository repository, RefSpec... refSpecs) throws Exception {
    Git git = new Git(repository);
    FetchCommand fetch = git.fetch();
    List<RefSpec> specs = new ArrayList<RefSpec>();
    if (refSpecs == null || refSpecs.length == 0) {
      specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
      specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
      specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
    } else {
      specs.addAll(Arrays.asList(refSpecs));
    }
    if (credentialsProvider != null) {
      fetch.setCredentialsProvider(credentialsProvider);
View Full Code Here

      int invalidSpecs = 0;
      int repairedSpecs = 0;
      List<String> specs = new ArrayList<String>();
      for (String spec : rc.getStringList("remote", name, "fetch")) {
        try {
          RefSpec rs = new RefSpec(spec);
          // valid spec
          specs.add(spec);
        } catch (IllegalArgumentException e) {
          // invalid spec
          invalidSpecs++;
View Full Code Here

    // create the remote config and save it
    RemoteConfig config = new RemoteConfig(repo.getConfig(), remote);
    config.addURI(u);

    final String dst = Constants.R_REMOTES + config.getName();
    RefSpec refSpec = new RefSpec();
    refSpec = refSpec.setForceUpdate(true);
    refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$

    config.addFetchRefSpec(refSpec);
    config.update(repo.getConfig());

    repo.getConfig().save();
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.