本文整理汇总了Java中org.eclipse.jgit.lib.RefUpdate.setRefLogMessage方法的典型用法代码示例。如果您正苦于以下问题:Java RefUpdate.setRefLogMessage方法的具体用法?Java RefUpdate.setRefLogMessage怎么用?Java RefUpdate.setRefLogMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.RefUpdate
的用法示例。
在下文中一共展示了RefUpdate.setRefLogMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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);
}
}
示例3: 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());
}
}
}
示例4: 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);
}
示例5: createUserBranch
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void createUserBranch(
Repository repo,
ObjectInserter oi,
ObjectId emptyTree,
Account.Id accountId,
Timestamp registeredOn)
throws IOException {
ObjectId id = createInitialEmptyCommit(oi, emptyTree, registeredOn);
String refName = RefNames.refsUsers(accountId);
RefUpdate ru = repo.updateRef(refName);
ru.setExpectedOldObjectId(ObjectId.zeroId());
ru.setNewObjectId(id);
ru.setRefLogIdent(serverIdent);
ru.setRefLogMessage(CREATE_ACCOUNT_MSG, false);
Result result = ru.update();
if (result != Result.NEW) {
throw new IOException(String.format("Failed to update ref %s: %s", refName, result.name()));
}
}
示例6: 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);
}
}
示例7: updateRef
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
protected void updateRef(String refName, String newValue, @Nullable String oldValue) {
try {
RefUpdate update = git.getRepository().updateRef(refName);
update.setNewObjectId(git.getRepository().resolve(newValue));
if (oldValue != null)
update.setExpectedOldObjectId(git.getRepository().resolve(oldValue));
update.setRefLogIdent(user);
update.setRefLogMessage("update ref", false);
GitUtils.updateRef(update);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例8: 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());
}
}
示例9: updateLabels
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateLabels(
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
throws IOException, OrmException, InvalidLabelsException {
try (RevWalk rw = new RevWalk(repo)) {
RefUpdate u = repo.updateRef(refName);
u.setExpectedOldObjectId(oldObjectId);
u.setForceUpdate(true);
u.setNewObjectId(writeLabels(repo, labels));
u.setRefLogIdent(serverIdent);
u.setRefLogMessage("Update star labels", true);
RefUpdate.Result result = u.update(rw);
switch (result) {
case NEW:
case FORCED:
case NO_CHANGE:
case FAST_FORWARD:
gitRefUpdated.fire(allUsers, u, null);
return;
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("Update star labels on ref %s failed: %s", refName, result.name()));
}
}
}
示例10: 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()));
}
}
示例11: fixPatchSetRef
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void fixPatchSetRef(ProblemInfo p, PatchSet ps) {
try {
RefUpdate ru = repo.updateRef(ps.getId().toRefName());
ru.setForceUpdate(true);
ru.setNewObjectId(ObjectId.fromString(ps.getRevision().get()));
ru.setRefLogIdent(newRefLogIdent());
ru.setRefLogMessage("Repair patch set ref", true);
RefUpdate.Result result = ru.update();
switch (result) {
case NEW:
case FORCED:
case FAST_FORWARD:
case NO_CHANGE:
p.status = Status.FIXED;
p.outcome = "Repaired patch set ref";
return;
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:
p.status = Status.FIX_FAILED;
p.outcome = "Failed to update patch set ref: " + result;
return;
}
} catch (IOException e) {
String msg = "Error fixing patch set ref";
log.warn(msg + ' ' + ps.getId().toRefName(), e);
p.status = Status.FIX_FAILED;
p.outcome = msg;
}
}
示例12: execute
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void execute() throws IOException, ConcurrentRefUpdateException {
final ObjectId headId = git.getLastCommit(Constants.R_HEADS + name);
final RefUpdate ru = git.getRepository().updateRef(Constants.R_HEADS + name);
if (headId == null) {
ru.setExpectedOldObjectId(ObjectId.zeroId());
} else {
ru.setExpectedOldObjectId(headId);
}
ru.setNewObjectId(commit.getId());
ru.setRefLogMessage(commit.getShortMessage(),
false);
forceUpdate(ru,
commit.getId());
}
示例13: save
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
* Save pending keys to the store.
*
* <p>One commit is created and the ref updated. The pending list is cleared if and only if the
* ref update succeeds, which allows for easy retries in case of lock failure.
*
* @param cb commit builder with at least author and identity populated; tree and parent are
* ignored.
* @return result of the ref update.
*/
public RefUpdate.Result save(CommitBuilder cb) throws PGPException, IOException {
if (toAdd.isEmpty() && toRemove.isEmpty()) {
return RefUpdate.Result.NO_CHANGE;
}
if (reader == null) {
load();
}
if (notes == null) {
notes = NoteMap.newEmptyMap();
}
ObjectId newTip;
try (ObjectInserter ins = repo.newObjectInserter()) {
for (PGPPublicKeyRing keyRing : toAdd.values()) {
saveToNotes(ins, keyRing);
}
for (Fingerprint fp : toRemove) {
deleteFromNotes(ins, fp);
}
cb.setTreeId(notes.writeTree(ins));
if (cb.getTreeId().equals(tip != null ? tip.getTree() : EMPTY_TREE)) {
return RefUpdate.Result.NO_CHANGE;
}
if (tip != null) {
cb.setParentId(tip);
}
if (cb.getMessage() == null) {
int n = toAdd.size() + toRemove.size();
cb.setMessage(String.format("Update %d public key%s", n, n != 1 ? "s" : ""));
}
newTip = ins.insert(cb);
ins.flush();
}
RefUpdate ru = repo.updateRef(PublicKeyStore.REFS_GPG_KEYS);
ru.setExpectedOldObjectId(tip);
ru.setNewObjectId(newTip);
ru.setRefLogIdent(cb.getCommitter());
ru.setRefLogMessage("Store public keys", true);
RefUpdate.Result result = ru.update();
reset();
switch (result) {
case FAST_FORWARD:
case NEW:
case NO_CHANGE:
toAdd.clear();
toRemove.clear();
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:
break;
}
return result;
}
示例14: insert
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void insert(Account account) throws IOException {
File path = getPath();
if (path != null) {
try (Repository repo = new FileRepository(path);
ObjectInserter oi = repo.newObjectInserter()) {
PersonIdent ident =
new PersonIdent(
new GerritPersonIdentProvider(flags.cfg).get(), account.getRegisteredOn());
Config accountConfig = new Config();
AccountConfig.writeToConfig(account, accountConfig);
DirCache newTree = DirCache.newInCore();
DirCacheEditor editor = newTree.editor();
final ObjectId blobId =
oi.insert(Constants.OBJ_BLOB, accountConfig.toText().getBytes(UTF_8));
editor.add(
new PathEdit(AccountConfig.ACCOUNT_CONFIG) {
@Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.REGULAR_FILE);
ent.setObjectId(blobId);
}
});
editor.finish();
ObjectId treeId = newTree.writeTree(oi);
CommitBuilder cb = new CommitBuilder();
cb.setTreeId(treeId);
cb.setCommitter(ident);
cb.setAuthor(ident);
cb.setMessage("Create Account");
ObjectId id = oi.insert(cb);
oi.flush();
String refName = RefNames.refsUsers(account.getId());
RefUpdate ru = repo.updateRef(refName);
ru.setExpectedOldObjectId(ObjectId.zeroId());
ru.setNewObjectId(id);
ru.setRefLogIdent(ident);
ru.setRefLogMessage("Create Account", false);
Result result = ru.update();
if (result != Result.NEW) {
throw new IOException(
String.format("Failed to update ref %s: %s", refName, result.name()));
}
account.setMetaId(id.name());
}
}
}
示例15: commit
import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/** Commits updates to the external IDs. */
public static ObjectId commit(
Project.NameKey project,
Repository repo,
RevWalk rw,
ObjectInserter ins,
ObjectId rev,
NoteMap noteMap,
String commitMessage,
PersonIdent committerIdent,
PersonIdent authorIdent,
@Nullable IdentifiedUser user,
GitReferenceUpdated gitRefUpdated)
throws IOException {
CommitBuilder cb = new CommitBuilder();
cb.setMessage(commitMessage);
cb.setTreeId(noteMap.writeTree(ins));
cb.setAuthor(authorIdent);
cb.setCommitter(committerIdent);
if (!rev.equals(ObjectId.zeroId())) {
cb.setParentId(rev);
} else {
cb.setParentIds(); // Ref is currently nonexistent, commit has no parents.
}
if (cb.getTreeId() == null) {
if (rev.equals(ObjectId.zeroId())) {
cb.setTreeId(emptyTree(ins)); // No parent, assume empty tree.
} else {
RevCommit p = rw.parseCommit(rev);
cb.setTreeId(p.getTree()); // Copy tree from parent.
}
}
ObjectId commitId = ins.insert(cb);
ins.flush();
RefUpdate u = repo.updateRef(RefNames.REFS_EXTERNAL_IDS);
u.setRefLogIdent(committerIdent);
u.setRefLogMessage("Update external IDs", false);
u.setExpectedOldObjectId(rev);
u.setNewObjectId(commitId);
RefUpdate.Result res = u.update();
switch (res) {
case NEW:
case FAST_FORWARD:
case NO_CHANGE:
case RENAMED:
case FORCED:
break;
case LOCK_FAILURE:
throw new LockFailureException("Updating external IDs failed with " + res, u);
case IO_FAILURE:
case NOT_ATTEMPTED:
case REJECTED:
case REJECTED_CURRENT_BRANCH:
case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON:
default:
throw new IOException("Updating external IDs failed with " + res);
}
gitRefUpdated.fire(project, u, user != null ? user.getAccount() : null);
return rw.parseCommit(commitId);
}