本文整理汇总了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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}