本文整理汇总了Java中org.eclipse.jgit.lib.RefUpdate.Result方法的典型用法代码示例。如果您正苦于以下问题:Java RefUpdate.Result方法的具体用法?Java RefUpdate.Result怎么用?Java RefUpdate.Result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.RefUpdate
的用法示例。
在下文中一共展示了RefUpdate.Result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: updateMasterRecord
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
*
* @param repo
* @param objectId
* @throws IOException
*/
public static void updateMasterRecord(Repository repo, ObjectId objectId) throws IOException {
RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
refUpdate.setNewObjectId(objectId);
final RefUpdate.Result result = refUpdate.forceUpdate();
switch (result) {
case NEW:
System.out.println("New commit!\n");
break;
case FORCED:
System.out.println("Forced change commit!\n");
break;
default: {
System.out.println(result.name());
}
}
}
示例3: forceUpdate
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void forceUpdate(final RefUpdate ru,
final ObjectId id) throws java.io.IOException, ConcurrentRefUpdateException {
final RefUpdate.Result rc = ru.forceUpdate();
switch (rc) {
case NEW:
case FORCED:
case FAST_FORWARD:
break;
case REJECTED:
case LOCK_FAILURE:
throw new ConcurrentRefUpdateException(JGitText.get().couldNotLockHEAD,
ru.getRef(),
rc);
default:
throw new JGitInternalException(MessageFormat.format(JGitText.get().updatingRefFailed,
Constants.HEAD,
id.toString(),
rc));
}
}
示例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));
}
}
示例5: updateReference
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateReference(
Repository repository,
String refName,
ObjectId currentObjectId,
ObjectId targetObjectId,
Timestamp timestamp)
throws IOException {
RefUpdate ru = repository.updateRef(refName);
ru.setExpectedOldObjectId(currentObjectId);
ru.setNewObjectId(targetObjectId);
ru.setRefLogIdent(getRefLogIdent(timestamp));
ru.setRefLogMessage("inline edit (amend)", false);
ru.setForceUpdate(true);
try (RevWalk revWalk = new RevWalk(repository)) {
RefUpdate.Result res = ru.update(revWalk);
if (res != RefUpdate.Result.NEW && res != RefUpdate.Result.FORCED) {
throw new IOException(
"cannot update "
+ ru.getName()
+ " in "
+ repository.getDirectory()
+ ": "
+ ru.getResult());
}
}
}
示例6: call
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
@Override
public RefUpdate.Result call() throws Exception {
Ref ref = repo.exactRef(refName);
afterReadRef.run();
ObjectId oldId;
if (ref == null) {
oldId = ObjectId.zeroId();
} else {
oldId = ref.getObjectId();
int next = parse(rw, oldId);
if (next >= value) {
// a concurrent write updated the ref already to this or a higher value
return RefUpdate.Result.NO_CHANGE;
}
}
return store(repo, rw, oldId, value);
}
示例7: store
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private RefUpdate.Result store(Repository repo, RevWalk rw, @Nullable ObjectId oldId, int val)
throws IOException {
ObjectId newId;
try (ObjectInserter ins = repo.newObjectInserter()) {
newId = ins.insert(OBJ_BLOB, Integer.toString(val).getBytes(UTF_8));
ins.flush();
}
RefUpdate ru = repo.updateRef(refName);
if (oldId != null) {
ru.setExpectedOldObjectId(oldId);
}
ru.disableRefLog();
ru.setNewObjectId(newId);
ru.setForceUpdate(true); // Required for non-commitish updates.
RefUpdate.Result result = ru.update(rw);
if (refUpdated(result)) {
gitRefUpdated.fire(projectName, ru, null);
}
return result;
}
示例8: save
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void save() throws Exception {
PersonIdent ident = new PersonIdent("A U Thor", "[email protected]");
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(ident);
cb.setCommitter(ident);
RefUpdate.Result result = store.save(cb);
switch (result) {
case NEW:
case FAST_FORWARD:
case FORCED:
break;
case IO_FAILURE:
case LOCK_FAILURE:
case NOT_ATTEMPTED:
case NO_CHANGE:
case REJECTED:
case REJECTED_CURRENT_BRANCH:
case RENAMED:
case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON:
default:
throw new AssertionError(result);
}
}
示例9: newSequence
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private RepoSequence newSequence(
String name,
final int start,
int batchSize,
Runnable afterReadRef,
Retryer<RefUpdate.Result> retryer) {
return new RepoSequence(
repoManager,
GitReferenceUpdated.DISABLED,
project,
name,
() -> start,
batchSize,
afterReadRef,
retryer);
}
示例10: 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;
}
示例11: push
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
@Override
public boolean push(@NotNull Repository repository, @NotNull ObjectId ReceiveId, @NotNull String branch, @NotNull User userInfo) throws SVNException, IOException {
final RefUpdate refUpdate = repository.updateRef(branch);
refUpdate.getOldObjectId();
refUpdate.setNewObjectId(ReceiveId);
runReceiveHook(repository, refUpdate, preReceive, userInfo);
runUpdateHook(repository, refUpdate, update, userInfo);
final RefUpdate.Result result = refUpdate.update();
switch (result) {
case REJECTED:
return false;
case NEW:
case FAST_FORWARD:
runReceiveHook(repository, refUpdate, postReceive, userInfo);
return true;
default:
log.error("Unexpected push error: {}", result);
throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_WRITE_ERROR, result.name()));
}
}
示例12: 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;
}
示例13: updateRef
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void updateRef(RefUpdate refUpdate) {
try {
RefUpdate.Result result = refUpdate.forceUpdate();
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);
}
}
示例14: linkRef
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void linkRef(RefUpdate refUpdate, String target) {
try {
RefUpdate.Result result = refUpdate.link(target);
if (result != RefUpdate.Result.FORCED && result != RefUpdate.Result.NEW && result != RefUpdate.Result.NO_CHANGE)
throw new RefUpdateException(result);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例15: updateRef
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateRef(Repository repo, PersonIdent ident, ObjectId newRevision, String refLogMsg)
throws IOException {
RefUpdate ru = repo.updateRef(getRefName());
ru.setRefLogIdent(ident);
ru.setNewObjectId(newRevision);
ru.setExpectedOldObjectId(revision);
ru.setRefLogMessage(refLogMsg, false);
RefUpdate.Result r = ru.update();
switch (r) {
case FAST_FORWARD:
case NEW:
case NO_CHANGE:
break;
case FORCED:
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(
"Failed to update " + getRefName() + " of " + project + ": " + r.name());
}
}