當前位置: 首頁>>代碼示例>>Java>>正文


Java URIish.toString方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.transport.URIish.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java URIish.toString方法的具體用法?Java URIish.toString怎麽用?Java URIish.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.transport.URIish的用法示例。


在下文中一共展示了URIish.toString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepare

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public static BackupService prepare(File localDir, URIish remoteUri) throws GitAPIException, IOException {
    Git local;
    try {
        local = Git.open(localDir);
    } catch (RepositoryNotFoundException e) {
        log.info("Initialising " + fullPath(localDir) + " as a git repo for backup purposes");
        local = Git.init().setDirectory(localDir).setBare(false).call();
    }
    log.info("Setting backup URL to " + remoteUri);
    if (local.remoteList().call().stream().anyMatch(remoteConfig -> remoteConfig.getName().equals("origin"))) {
        RemoteSetUrlCommand remoteSetUrlCommand = local.remoteSetUrl();
        remoteSetUrlCommand.setName("origin");
        remoteSetUrlCommand.setUri(remoteUri);
        remoteSetUrlCommand.call();
    } else {
        RemoteAddCommand remoteAddCommand = local.remoteAdd();
        remoteAddCommand.setName("origin");
        remoteAddCommand.setUri(remoteUri);
        remoteAddCommand.call();
    }

    URL inputUrl = BackupService.class.getResource("/dataDirGitIgnore.txt");
    FileUtils.copyURLToFile(inputUrl, new File(localDir, ".gitignore"));

    return new BackupService(local, remoteUri.toString());
}
 
開發者ID:danielflower,項目名稱:app-runner,代碼行數:27,代碼來源:BackupService.java

示例2: GitTransportUpdate

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
GitTransportUpdate (URIish uri, TrackingRefUpdate update) {
    this.localName = stripRefs(update.getLocalName());
    this.remoteName = stripRefs(update.getRemoteName());
    this.oldObjectId = update.getOldObjectId() == null || ObjectId.zeroId().equals(update.getOldObjectId()) ? null : update.getOldObjectId().getName();
    this.newObjectId = update.getNewObjectId() == null || ObjectId.zeroId().equals(update.getNewObjectId()) ? null : update.getNewObjectId().getName();
    this.result = GitRefUpdateResult.valueOf((update.getResult() == null 
            ? RefUpdate.Result.NOT_ATTEMPTED 
            : update.getResult()).name());
    this.uri = uri.toString();
    this.type = getType(update.getLocalName());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:GitTransportUpdate.java

示例3: fromSqsJob

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public static RepoInfo fromSqsJob(SQSJob sqsJob) {
    if (sqsJob == null) {
        return null;
    }

    RepoInfo repoInfo = new RepoInfo();

    List<SCM> scms = sqsJob.getScmList();
    List<String> codeCommitUrls = new ArrayList<>();
    List<String> nonCodeCommitUrls = new ArrayList<>();
    List<String> branches = new ArrayList<>();

    for (SCM scm : scms) {
        if (scm instanceof GitSCM) {//TODO refactor to visitor
            GitSCM git = (GitSCM) scm;
            List<RemoteConfig> repos = git.getRepositories();
            for (RemoteConfig repo : repos) {
                for (URIish urIish : repo.getURIs()) {
                    String url = urIish.toString();
                    if (StringUtils.isCodeCommitRepo(url)) {
                        codeCommitUrls.add(url);
                    }
                    else {
                        nonCodeCommitUrls.add(url);
                    }
                }
            }

            for (BranchSpec branchSpec : git.getBranches()) {
                branches.add(branchSpec.getName());
            }
        }
    }

    repoInfo.nonCodeCommitUrls = nonCodeCommitUrls;
    repoInfo.codeCommitUrls = codeCommitUrls;
    repoInfo.branches = branches;
    return repoInfo;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:40,代碼來源:RepoInfo.java

示例4: populateFromGitSCM

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static boolean populateFromGitSCM(BuildConfig buildConfig, BuildSource source, GitSCM gitSCM, String ref) {
	source.setType("Git");
	List<RemoteConfig> repositories = gitSCM.getRepositories();
	if (repositories != null && repositories.size() > 0) {
		RemoteConfig remoteConfig = repositories.get(0);
		List<URIish> urIs = remoteConfig.getURIs();
		if (urIs != null && urIs.size() > 0) {
			URIish urIish = urIs.get(0);
			String gitUrl = urIish.toString();
			if (gitUrl != null && gitUrl.length() > 0) {
				if (StringUtils.isEmpty(ref)) {
					List<BranchSpec> branches = gitSCM.getBranches();
					if (branches != null && branches.size() > 0) {
						BranchSpec branchSpec = branches.get(0);
						String branch = branchSpec.getName();
						while (branch.startsWith("*") || branch.startsWith("/")) {
							branch = branch.substring(1);
						}
						if (!branch.isEmpty()) {
							ref = branch;
						}
					}
				}
				OpenShiftUtils.updateGitSourceUrl(buildConfig, gitUrl, ref);
				return true;
			}
		}
	}
	return false;
}
 
開發者ID:jenkinsci,項目名稱:openshift-sync-plugin,代碼行數:31,代碼來源:BuildConfigToJobMapper.java

示例5: toSshUri

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private URIish toSshUri(URIish uri) throws URISyntaxException {
  String uriStr = uri.toString();
  if (uri.getHost() != null && uriStr.startsWith(GERRIT_ADMIN_PROTOCOL_PREFIX)) {
    return new URIish(uriStr.substring(0, GERRIT_ADMIN_PROTOCOL_PREFIX.length()));
  }
  String rawPath = uri.getRawPath();
  if (!rawPath.endsWith("/")) {
    rawPath = rawPath + "/";
  }
  URIish sshUri = new URIish("ssh://" + rawPath);
  if (sshUri.getPort() < 0) {
    sshUri = sshUri.setPort(SshAddressesModule.DEFAULT_PORT);
  }
  return sshUri;
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:16,代碼來源:GerritSshApi.java

示例6: JGitWrapper

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public JGitWrapper(SharedPreferences preferences) throws Exception {
    localPath = preferences.getString("git_local_path", "");
    if (TextUtils.isEmpty(localPath))
        throw new IllegalArgumentException("Must specify local git path");

    String url = preferences.getString("git_url", "");
    if (TextUtils.isEmpty(url))
        throw new IllegalArgumentException("Must specify remote git url");
    try {
        URIish urIish = new URIish(url);
        if (urIish.getUser() == null) {
            String username = preferences.getString("git_username", "");
            urIish = urIish.setUser(username);
        }
        remotePath = urIish.toString();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Invalid remote git url");
    }

    branch = preferences.getString("git_branch", "master");
    if (branch.isEmpty())
        throw new IllegalArgumentException("Must specify a git branch");

    commitAuthor = preferences.getString("git_commit_author", "");
    commitEmail = preferences.getString("git_commit_email", "");

    String mergeStrategyString = preferences.getString("git_merge_strategy", "theirs");
    mergeStrategy = MergeStrategy.get(mergeStrategyString);
    if (mergeStrategy == null)
        throw new IllegalArgumentException("Invalid merge strategy: " + mergeStrategyString);

    setupJGitAuthentication(preferences);
}
 
開發者ID:hdweiss,項目名稱:mOrgAnd,代碼行數:34,代碼來源:JGitWrapper.java

示例7: load

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public boolean load(File repoFile) {
	Repository repository;
	Git git = null;
	
	try {
		repository = new FileRepositoryBuilder().setGitDir(repoFile)
				.setMustExist(true)
				.readEnvironment()
				.build();
	    git = new Git(repository);

	    branchFull = repository.getFullBranch();
	    branchShort = repository.getBranch();
	    state = repository.getRepositoryState().getDescription();

		for (Ref branch : git.branchList().call()) {
			if (branch.getName().equals(branchFull)) {
				BranchTrackingStatus bts = BranchTrackingStatus.of(repository, branchFull); 
				
				if (bts != null) {
					RemoteConfig rc = new RemoteConfig(repository.getConfig(), repository.getRemoteName(bts.getRemoteTrackingBranch()));
					
					for (URIish uri : rc.getURIs()) {
						if (uri.isRemote() && uri.getHost().toLowerCase().equals("github.com")) {
							remote = new GitInformationRemote();
							
							remote.branch = bts.getRemoteTrackingBranch();
							remote.uri = uri.toString();
							remote.link = "http://" + uri.getHost() + uri.getPath().replace(".git", "");
							remote.name = uri.getHumanishName();
							
							remote.ahead = bts.getAheadCount();
							remote.behind = bts.getBehindCount();
						}
					}
				}

				commits = loadCommits(repository, git, branch);
			}
		}
	    
	    git.close();
	} catch (IOException | GitAPIException | URISyntaxException e) {
		e.printStackTrace();
		
		isRepository = false;
		
		if (git != null) git.close();
		return false;
	}

	isRepository = true;
	return true;
}
 
開發者ID:Mikescher,項目名稱:jQCCounter,代碼行數:55,代碼來源:GitInformation.java


注:本文中的org.eclipse.jgit.transport.URIish.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。