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


Java RefUpdate.delete方法代码示例

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


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

示例1: run

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的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);
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DeleteTagCommand.java

示例2: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void deleteRef(RefUpdate refUpdate) {
	try {
		refUpdate.setForceUpdate(true);
		RefUpdate.Result result = refUpdate.delete();
        if (result == RefUpdate.Result.LOCK_FAILURE
        		&& refUpdate.getExpectedOldObjectId() != null
        		&& !refUpdate.getExpectedOldObjectId().equals(refUpdate.getOldObjectId())) {
        	throw new ObsoleteCommitException(refUpdate.getOldObjectId());
        } else if (result != RefUpdate.Result.FAST_FORWARD && result != RefUpdate.Result.FORCED
        		&& result != RefUpdate.Result.NEW && result != RefUpdate.Result.NO_CHANGE) {
        	throw new RefUpdateException(result);
        } 
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:17,代码来源:GitUtils.java

示例3: tagDelete

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
@Override
public void tagDelete(String name) throws GitException {
  try {
    Ref tagRef = repository.findRef(name);
    if (tagRef == null) {
      throw new GitException("Tag " + name + " not found. ");
    }

    RefUpdate updateRef = repository.updateRef(tagRef.getName());
    updateRef.setRefLogMessage("tag deleted", false);
    updateRef.setForceUpdate(true);
    Result deleteResult = updateRef.delete();
    if (deleteResult != Result.FORCED && deleteResult != Result.FAST_FORWARD) {
      throw new GitException(format(ERROR_TAG_DELETE, name, deleteResult));
    }
  } catch (IOException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:JGitConnection.java

示例4: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private static void deleteRef(Repository repo, ChangeEdit edit) throws IOException {
  String refName = edit.getRefName();
  RefUpdate ru = repo.updateRef(refName, true);
  ru.setExpectedOldObjectId(edit.getEditCommit());
  ru.setForceUpdate(true);
  RefUpdate.Result result = ru.delete();
  switch (result) {
    case FORCED:
    case NEW:
    case NO_CHANGE:
      break;
    case FAST_FORWARD:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new IOException(String.format("Failed to delete ref %s: %s", refName, result));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:ChangeEditUtil.java

示例5: deleteUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void deleteUserBranch(
    Repository repo,
    Project.NameKey project,
    GitReferenceUpdated gitRefUpdated,
    @Nullable IdentifiedUser user,
    PersonIdent refLogIdent,
    Account.Id accountId)
    throws IOException {
  String refName = RefNames.refsUsers(accountId);
  Ref ref = repo.exactRef(refName);
  if (ref == null) {
    return;
  }

  RefUpdate ru = repo.updateRef(refName);
  ru.setExpectedOldObjectId(ref.getObjectId());
  ru.setNewObjectId(ObjectId.zeroId());
  ru.setForceUpdate(true);
  ru.setRefLogIdent(refLogIdent);
  ru.setRefLogMessage("Delete Account", true);
  Result result = ru.delete();
  if (result != Result.FORCED) {
    throw new IOException(String.format("Failed to delete ref %s: %s", refName, result.name()));
  }
  gitRefUpdated.fire(project, ru, user != null ? user.getAccount() : null);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AccountsUpdate.java

示例6: onOptionsItemSelected

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.i(TAG, "onOptionsItemSelected " + item);
    switch (item.getItemId()) {
        case android.R.id.home:
            return homewardsWith(this, manageRepoIntent(repo()));
        case DELETE_ID:
            try {
                RefUpdate update = repo().updateRef(tagRef.getName());
                update.setForceUpdate(true);
                // update.setNewObjectId(head);
                // update.setForceUpdate(force || remote);
                Result result = update.delete();
                Toast.makeText(this, "Tag deletion : " + result.name(), Toast.LENGTH_SHORT).show();
                finish();
            } catch (IOException e) {
                Log.e(TAG, "Couldn't delete " + revTag.getName(), e);
                throw new RuntimeException(e);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:24,代码来源:TagViewer.java

示例7: deleteBranchRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Deletes the specified branch ref.
 * 
 * @param repository
 * @param branch
 * @return true if successful
 */
public static boolean deleteBranchRef(Repository repository, String branch) {
	String branchName = branch;
	if (!branchName.startsWith(Constants.R_HEADS)) {
		branchName = Constants.R_HEADS + branch;
	}

	try {
		RefUpdate refUpdate = repository.updateRef(branchName, false);
		refUpdate.setForceUpdate(true);
		RefUpdate.Result result = refUpdate.delete();
		switch (result) {
		case NEW:
		case FORCED:
		case NO_CHANGE:
		case FAST_FORWARD:
			return true;
		default:
			LOGGER.error(MessageFormat.format("{0} failed to delete to {1} returned result {2}", repository.getDirectory().getAbsolutePath(),
					branchName, result));
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to delete {1}", branchName);
	}
	return false;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:33,代码来源:JGitUtils.java

示例8: deleteBranchRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Deletes the specified branch ref.
 *  
 * @param repository
 * @param branch
 * @return true if successful
 */
public static boolean deleteBranchRef(Repository repository, String branch) {
	String branchName = branch;
	if (!branchName.startsWith(Constants.R_HEADS)) {
		branchName = Constants.R_HEADS + branch;
	}

	try {
		RefUpdate refUpdate = repository.updateRef(branchName, false);
		refUpdate.setForceUpdate(true);
		RefUpdate.Result result = refUpdate.delete();
		switch (result) {
		case NEW:
		case FORCED:
		case NO_CHANGE:
		case FAST_FORWARD:
			return true;				
		default:
			LOGGER.error(MessageFormat.format("{0} failed to delete to {1} returned result {2}",
					repository.getDirectory().getAbsolutePath(), branchName, result));
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to delete {1}", branchName);
	}
	return false;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:33,代码来源:JGitUtils.java

示例9: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/** {@inheritDoc} */
   public void deleteRef(String refName) throws GitException, InterruptedException {
refName = refName.replace(' ', '_');
try (Repository repo = getRepository()) {
    RefUpdate refUpdate = repo.updateRef(refName);
    // Required, even though this is a forced delete.
    refUpdate.setNewObjectId(repo.getRef(Constants.HEAD).getObjectId());
    refUpdate.setForceUpdate(true);
    switch (refUpdate.delete()) {
    case NOT_ATTEMPTED:
    case LOCK_FAILURE:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case IO_FAILURE:
    case RENAMED:
	throw new GitException("Could not delete " + refName);
    }
} catch (IOException e) {
    throw new GitException("Could not delete " + refName, e);
}
   }
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:22,代码来源:JGitAPIImpl.java

示例10: prune

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void prune(RemoteConfig repository) throws GitException {
    try (Repository gitRepo = getRepository()) {
        String remote = repository.getName();
        String prefix = "refs/remotes/" + remote + "/";

        Set<String> branches = listRemoteBranches(remote);

        for (Ref r : new ArrayList<>(gitRepo.getAllRefs().values())) {
            if (r.getName().startsWith(prefix) && !branches.contains(r.getName())) {
                // delete this ref
                RefUpdate update = gitRepo.updateRef(r.getName());
                update.setRefLogMessage("remote branch pruned", false);
                update.setForceUpdate(true);
                Result res = update.delete();
            }
        }
    } catch (URISyntaxException | IOException e) {
        throw new GitException(e);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:22,代码来源:JGitAPIImpl.java

示例11: deleteBranchRemotely

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void deleteBranchRemotely(final Repository repository, final String branch) throws Exception {
	PushOperationSpecification spec = 
			BranchingUtils.setupPush(repository, ":" + branch ); //$NON-NLS-1$
	
	PushOperationUI op = new PushOperationUI(repository, spec, false) {
		
		@Override
		public PushOperationResult execute(IProgressMonitor monitor)
				throws CoreException {
			PushOperationResult result = super.execute(monitor);
			for (URIish uri: result.getURIs()) {
				if (result.getErrorMessage(uri) != null) {
					return result;
				}
			}
			try {
				//delete reference from local repo
				RefUpdate updateRef = repository.updateRef("refs/remotes/origin/" + branch.substring("refs/heads/".length())); //$NON-NLS-1$ //$NON-NLS-2$
				updateRef.setForceUpdate(true);
				updateRef.delete();
			} catch (Exception e) {
	        	RepositoryUtils.handleException(e);
			}
			return result;
		}
		
	};
	op.setCredentialsProvider(new EGitCredentialsProvider());
	op.start();
}
 
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:31,代码来源:DeleteFeatureBranchCommand.java

示例12: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
    throws IOException, OrmException {
  RefUpdate u = repo.updateRef(refName);
  u.setForceUpdate(true);
  u.setExpectedOldObjectId(oldObjectId);
  u.setRefLogIdent(serverIdent);
  u.setRefLogMessage("Unstar change", true);
  RefUpdate.Result result = u.delete();
  switch (result) {
    case FORCED:
      gitRefUpdated.fire(allUsers, u, null);
      return;
    case NEW:
    case NO_CHANGE:
    case FAST_FORWARD:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new OrmException(
          String.format("Delete star ref %s failed: %s", refName, result.name()));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:StarredChangesUtil.java

示例13: deleteOriginalRefs

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void deleteOriginalRefs() throws IOException {
	try (RevWalk revWalk = new RevWalk(repository)) {
		Collection<Ref> refs = new ArrayList<>();
		RefDatabase refDatabase = repository.getRefDatabase();
		Map<String, Ref> originalBranches = refDatabase.getRefs("refs/heads/original/");
		Map<String, Ref> originalTags = refDatabase.getRefs("refs/tags/original/");
		refs.addAll(originalBranches.values());
		refs.addAll(originalTags.values());
		for (Ref originalRef : refs) {
			RefUpdate refUpdate = repository.updateRef(originalRef.getName());
			refUpdate.setForceUpdate(true);
			refUpdate.delete(revWalk);
		}
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:16,代码来源:RepoMerger.java


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