Add ssh command to show current sequence value

Change-Id: Ifcbff0943bbdacfd792a4c2454492522dec8609a
This commit is contained in:
David Ostrovsky
2019-11-09 14:12:43 -08:00
parent 8506c6fdfb
commit 4f8df3399b
9 changed files with 173 additions and 0 deletions

View File

@@ -291,4 +291,23 @@ public class RepoSequence {
ObjectId newId = ins.insert(OBJ_BLOB, Integer.toString(val).getBytes(UTF_8));
return new ReceiveCommand(ObjectId.zeroId(), newId, RefNames.REFS_SEQUENCES + name);
}
public int current() {
counterLock.lock();
try (Repository repo = repoManager.openRepository(projectName);
RevWalk rw = new RevWalk(repo)) {
Optional<IntBlob> blob = IntBlob.parse(repo, refName, rw);
int current;
if (!blob.isPresent()) {
current = seed.get();
} else {
current = blob.get().value();
}
return current;
} catch (IOException e) {
throw new StorageException(e);
} finally {
counterLock.unlock();
}
}
}

View File

@@ -128,4 +128,16 @@ public class Sequences {
return groupSeq.next();
}
}
public int currentChangeId() {
return changeSeq.current();
}
public int currentAccountId() {
return accountSeq.current();
}
public int currentGroupId() {
return groupSeq.current();
}
}