本文整理匯總了Java中org.eclipse.jgit.lib.Ref.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Ref.getName方法的具體用法?Java Ref.getName怎麽用?Java Ref.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.lib.Ref
的用法示例。
在下文中一共展示了Ref.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
protected void run () throws GitException {
Repository repository = getRepository();
Ref currentRef = repository.getTags().get(tagName);
if (currentRef == null) {
throw new GitException.MissingObjectException(tagName, GitObjectType.TAG);
}
String fullName = currentRef.getName();
try {
RefUpdate update = repository.updateRef(fullName);
update.setRefLogMessage("tag deleted", false);
update.setForceUpdate(true);
Result deleteResult = update.delete();
switch (deleteResult) {
case IO_FAILURE:
case LOCK_FAILURE:
case REJECTED:
throw new GitException.RefUpdateException("Cannot delete tag " + tagName, GitRefUpdateResult.valueOf(deleteResult.name()));
}
} catch (IOException ex) {
throw new GitException(ex);
}
}
示例2: fetchAndCreateNewRevsWalk
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
RevWalk walk = new RevWalk(repository);
for (TrackingRefUpdate newRef : newRemoteRefs) {
if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
}
}
for (ObjectId oldRef : currentRemoteRefs) {
walk.markUninteresting(walk.parseCommit(oldRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例3: createAllRevsWalk
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
if (branch == null || refName.endsWith("/" + branch)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
}
RevWalk walk = new RevWalk(repository);
for (ObjectId newRef : currentRemoteRefs) {
walk.markStart(walk.parseCommit(newRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例4: fetchAndCreateNewRevsWalk
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
RevWalk walk = new RevWalk(repository);
for (TrackingRefUpdate newRef : newRemoteRefs) {
if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
}
}
for (ObjectId oldRef : currentRemoteRefs) {
walk.markUninteresting(walk.parseCommit(oldRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例5: createAllRevsWalk
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
if (branch == null || refName.endsWith("/" + branch)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
}
RevWalk walk = new RevWalk(repository);
for (ObjectId newRef : currentRemoteRefs) {
walk.markStart(walk.parseCommit(newRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例6: getBranchObjectId
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
protected ObjectId getBranchObjectId(Git git) {
Ref branchRef = null;
try {
String branchRevName = "refs/heads/" + branch;
List<Ref> branches = git.branchList().call();
for (Ref ref : branches) {
String revName = ref.getName();
if (Objects.equals(branchRevName, revName)) {
branchRef = ref;
break;
}
}
} catch (GitAPIException e) {
LOG.warn("Failed to find branches " + e, e);
}
ObjectId branchObjectId = null;
if (branchRef != null) {
branchObjectId = branchRef.getObjectId();
}
return branchObjectId;
}
示例7: prepareTarget
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private void prepareTarget() throws IOException {
if(target == null)
throw new NoBranchException();
if(!detach) {
if(BranchUtils.branchExists(target, repo)) {
Ref branchRef = RefUtils.getBranchRef(target, repo);
targetBranch = branchRef.getName();
targetCommit = CommitUtils.getCommit(targetBranch, repo);
}
}
if(targetCommit == null) {
if(CommitUtils.exists(target, repo))
targetCommit = CommitUtils.getCommit(target, repo);
else
throw new NoSuchBranchException(target);
}
}
示例8: branchCreate
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
public Branch branchCreate(String name, String startPoint) throws GitException {
CreateBranchCommand createBranchCommand = getGit().branchCreate().setName(name);
if (startPoint != null) {
createBranchCommand.setStartPoint(startPoint);
}
try {
Ref brRef = createBranchCommand.call();
String refName = brRef.getName();
String displayName = Repository.shortenRefName(refName);
return newDto(Branch.class)
.withName(refName)
.withDisplayName(displayName)
.withActive(false)
.withRemote(false);
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
示例9: getBranchObjectId
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
protected ObjectId getBranchObjectId(Git git, String branch) {
Ref branchRef = null;
try {
String branchRevName = "refs/heads/" + branch;
List<Ref> branches = git.branchList().call();
for (Ref ref : branches) {
String revName = ref.getName();
if (Objects.equals(branchRevName, revName)) {
branchRef = ref;
break;
}
}
} catch (GitAPIException e) {
LOG.warn("Failed to find branches " + e, e);
}
ObjectId branchObjectId = null;
if (branchRef != null) {
branchObjectId = branchRef.getObjectId();
}
return branchObjectId;
}
示例10: createBranchInfo
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private BranchInfo createBranchInfo(
PermissionBackend.ForRef perm,
Ref ref,
ProjectState projectState,
CurrentUser user,
Set<String> targets) {
BranchInfo info = new BranchInfo();
info.ref = ref.getName();
info.revision = ref.getObjectId() != null ? ref.getObjectId().name() : null;
info.canDelete =
!targets.contains(ref.getName()) && perm.testOrFalse(RefPermission.DELETE) ? true : null;
BranchResource rsrc = new BranchResource(projectState, user, ref);
for (UiAction.Description d : uiActions.from(branchViews, rsrc)) {
if (info.actions == null) {
info.actions = new TreeMap<>();
}
info.actions.put(d.getId(), new ActionInfo(d));
}
List<WebLinkInfo> links = webLinks.getBranchLinks(projectState.getName(), ref.getName());
info.webLinks = links.isEmpty() ? null : links;
return info;
}
示例11: createBranch
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
public String createBranch(String commitId, String branchName) {
Ref result = null;
CreateBranchCommand branchCreate = _git.branchCreate();
branchCreate.setName(branchName);
branchCreate.setStartPoint(commitId);
try {
result = branchCreate.call();
} catch (Throwable e) {
throw new RuntimeException(String.format(
"Failed creating branch: %s for commit [%s]",
branchName,
commitId), e);
}
return result.getName();
}
示例12: checkout
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
public String checkout(
String branchName,
boolean useBranchNameAsStartPoint,
boolean createBranch,
boolean useForce) {
CheckoutCommand command = _git.checkout();
command.setCreateBranch(createBranch);
command.setForce(useForce);
command.setName(branchName);
if (useBranchNameAsStartPoint) {
command.setStartPoint(REFS_REMOTES + branchName);
}
Ref ref = null;
try {
ref = command.call();
} catch (Throwable e) {
throw new RuntimeException(
String.format("Failed to checkout branch [%s]", branchName),
e);
}
return ref.getName();
}
示例13: run
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
protected void run () throws GitException {
Repository repository = getRepository();
try {
Ref ref = repository.getRef(trackedBranchName);
if (ref == null) {
throw new GitException(MessageFormat.format(Utils.getBundle(SetUpstreamBranchCommand.class)
.getString("MSG_Error_UpdateTracking_InvalidReference"), trackedBranchName)); //NOI18N)
}
String remote = null;
String branchName = ref.getName();
StoredConfig config = repository.getConfig();
if (branchName.startsWith(Constants.R_REMOTES)) {
String[] elements = branchName.split("/", 4);
remote = elements[2];
if (config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION).contains(remote)) {
branchName = Constants.R_HEADS + elements[3];
setupRebaseFlag(repository);
} else {
// remote not yet set
remote = null;
}
}
if (remote == null) {
remote = "."; //NOI18N
}
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName,
ConfigConstants.CONFIG_KEY_REMOTE, remote);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName,
ConfigConstants.CONFIG_KEY_MERGE, branchName);
config.save();
} catch (IOException ex) {
throw new GitException(ex);
}
ListBranchCommand branchCmd = new ListBranchCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
branchCmd.run();
Map<String, GitBranch> branches = branchCmd.getBranches();
branch = branches.get(localBranchName);
}
示例14: getRefName
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
/**
* Eliminates part of the ref's name that equals knon prefixes such as refs/heads/, refs/remotes/ etc.
* @param ref
* @return
*/
public static String getRefName (Ref ref) {
String name = ref.getName();
for (String prefix : Arrays.asList(Constants.R_HEADS, Constants.R_REMOTES, Constants.R_TAGS, Constants.R_REFS)) {
if (name.startsWith(prefix)) {
name = name.substring(prefix.length());
}
}
return name;
}
示例15: checkoutAllBranches
import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private void checkoutAllBranches(Repository repository) throws GitAPIException {
final Git git = Git.wrap(repository);
for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) {
final String refName = ref.getName();
final String branchName = refName.substring(refName.lastIndexOf('/') + 1);
try {
git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call();
} catch (RefAlreadyExistsException e) {
LOGGER.warning("Already exists, so ignoring " + e.getMessage());
}
}
}