当前位置: 首页>>代码示例>>Java>>正文


Java Revision.getBranches方法代码示例

本文整理汇总了Java中hudson.plugins.git.Revision.getBranches方法的典型用法代码示例。如果您正苦于以下问题:Java Revision.getBranches方法的具体用法?Java Revision.getBranches怎么用?Java Revision.getBranches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hudson.plugins.git.Revision的用法示例。


在下文中一共展示了Revision.getBranches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decorateRevisionToBuild

import hudson.plugins.git.Revision; //导入方法依赖的package包/类
@Override
public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException, GitException {
    listener.getLogger().println("Merging " + targetBranch.getName() + " commit " + targetBranch.getRevision().getHash() + " into merge-request head commit " + rev.getSha1String());
    checkout(scm, build, git, listener, rev);
    try {
        git.setAuthor("Jenkins", /* could parse out of JenkinsLocationConfiguration.get().getAdminAddress() but seems overkill */"[email protected]");
        git.setCommitter("Jenkins", "[email protected]");
        MergeCommand cmd = git.merge().setRevisionToMerge(ObjectId.fromString(targetBranch.getRevision().getHash()));
        for (GitSCMExtension ext : scm.getExtensions()) {
            // By default we do a regular merge, allowing it to fast-forward.
            ext.decorateMergeCommand(scm, build, git, listener, cmd);
        }
        cmd.execute();
    } catch (GitException e) {
        // Try to revert merge conflict markers.
        checkout(scm, build, git, listener, rev);
        throw e;
    }
    build.addAction(new MergeRecord(targetBranch.getRefSpec().destinationRef(targetBranch.getName()), targetBranch.getRevision().getHash())); // does not seem to be used, but just in case
    ObjectId mergeRev = git.revParse(Constants.HEAD);
    listener.getLogger().println("Merge succeeded, producing " + mergeRev.name());
    return new Revision(mergeRev, rev.getBranches()); // note that this ensures Build.revision != Build.marked
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:24,代码来源:GitLabSCMMergeRequestHead.java

示例2: fromPull

import hudson.plugins.git.Revision; //导入方法依赖的package包/类
public static String fromPull(BuildData buildData, Optional<String> organization) {
    Set<String> remoteUrls = buildData.getRemoteUrls();

    checkArgument(!remoteUrls.isEmpty(), "buildData does not contain any remote URLs");

    Revision lastBuiltRevision = buildData.getLastBuiltRevision();
    Collection<hudson.plugins.git.Branch> scmBranches = lastBuiltRevision.getBranches();

    checkArgument(!scmBranches.isEmpty(), "buildData last revision does not contain any branches");

    String firstRemoteUrl = remoteUrls.iterator().next();
    Repository repository = new Repository(firstRemoteUrl);

    hudson.plugins.git.Branch firstScmBranch = scmBranches.iterator().next();
    Branch branch = new Branch(firstScmBranch);

    return generateRemoteImageName(organization, repository, branch);
}
 
开发者ID:spoonapps,项目名称:jenkins,代码行数:19,代码来源:RemoteImageGenerator.java

示例3: setupSubmoduleUrls

import hudson.plugins.git.Revision; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Set up submodule URLs so that they correspond to the remote pertaining to
 * the revision that has been checked out.
 */
public void setupSubmoduleUrls( Revision rev, TaskListener listener ) throws GitException, InterruptedException {
    String remote = null;

    // try to locate the remote repository from where this commit came from
    // (by using the heuristics that the branch name, if available, contains the remote name)
    // if we can figure out the remote, the other setupSubmoduleUrls method
    // look at its URL, and if it's a non-bare repository, we attempt to retrieve modules
    // from this checked out copy.
    //
    // the idea is that you have something like tree-structured repositories: at the root you have corporate central repositories that you
    // ultimately push to, which all .gitmodules point to, then you have intermediate team local repository,
    // which is assumed to be a non-bare repository (say, a checked out copy on a shared server accessed via SSH)
    //
    // the abovementioned behaviour of the Git plugin makes it pick up submodules from this team local repository,
    // not the corporate central.
    //
    // (Kohsuke: I have a bit of hesitation/doubt about such a behaviour change triggered by seemingly indirect
    // evidence of whether the upstream is bare or not (not to mention the fact that you can't reliably
    // figure out if the repository is bare or not just from the URL), but that's what apparently has been implemented
    // and we care about the backward compatibility.)
    //
    // note that "figuring out which remote repository the commit came from" isn't a well-defined
    // question, and this is really a heuristics. The user might be telling us to build a specific SHA1.
    // or maybe someone pushed directly to the workspace and so it may not correspond to any remote branch.
    // so if we fail to figure this out, we back out and avoid being too clever. See JENKINS-10060 as an example
    // of where our trying to be too clever here is breaking stuff for people.
    for (Branch br : rev.getBranches()) {
        String b = br.getName();
        if (b != null) {
            int slash = b.indexOf('/');

            if ( slash != -1 )
                remote = getDefaultRemote( b.substring(0,slash) );
        }

        if (remote!=null)   break;
    }

    if (remote==null)
        remote = getDefaultRemote();

    if (remote!=null)
        setupSubmoduleUrls( remote, listener );
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:51,代码来源:CliGitAPIImpl.java


注:本文中的hudson.plugins.git.Revision.getBranches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。