Skip to content

Commit

Permalink
Merge pull request #187 from dotindustries/feature/temporal_support
Browse files Browse the repository at this point in the history
feat: continue temporal support
  • Loading branch information
nadilas authored Jun 23, 2024
2 parents 551bb7f + c21308b commit f388abd
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 105 deletions.
6 changes: 3 additions & 3 deletions apps/ogre-cli/source/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const run = async ({name = 'author'}: {name?: string}) => {
r.data.description = 'first description';
await r.commit('initial commit', author);

r.checkout('desc-up', true);
await r.checkout('desc-up', true);
r.data.description = 'some longer different description';
await r.commit('change desc', author);

Expand All @@ -54,8 +54,8 @@ const run = async ({name = 'author'}: {name?: string}) => {
r.data.description = 'yet another correction';
await r.commit('typo fix', author);

r.checkout('main');
r.merge('desc-up');
await r.checkout('main');
await r.merge('desc-up');

const history = r.getHistory();

Expand Down
6 changes: 3 additions & 3 deletions apps/ogre-demo/components/DemoRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const DemoRepo: React.FC<DemoRepoProps> = ({}) => {
r.data.description = "first description";
await r.commit("initial commit", author);

r.checkout("description", true);
await r.checkout("description", true);
r.data.description = "some longer different description";
await r.commit("change desc", author);

Expand All @@ -38,8 +38,8 @@ export const DemoRepo: React.FC<DemoRepoProps> = ({}) => {
r.data.description = "yet another correction";
await r.commit("typo fix", author);

r.checkout("main");
r.merge("description");
await r.checkout("main");
await r.merge("description");

setRepository(r);
};
Expand Down
6 changes: 3 additions & 3 deletions apps/ogre-demo/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const code = `
r.data.description = 'first description'
await r.commit('initial commit', author)
r.checkout('description', true)
await r.checkout('description', true)
r.data.description = 'some longer different description'
await r.commit('change desc', author)
Expand All @@ -144,8 +144,8 @@ const code = `
r.data.description = 'yet another correction'
await r.commit('typo fix', author)
r.checkout('main')
r.merge('description')
await r.checkout('main')
await r.merge('description')
return r
}
Expand Down
8 changes: 8 additions & 0 deletions packages/ogre/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"private": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"source": "./src/index.ts",
"import": "./lib/index.js",
"require": "./lib/index.js"
},
"./lib/*": "./lib/*.js"
},
"type": "module",
"scripts": {
"build": "tsc -p tsconfig.build.json",
Expand Down
25 changes: 11 additions & 14 deletions packages/ogre/src/checkout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test("checkout prev commit", async (t) => {
addOneStep(obj);
await repo.commit("first step", testAuthor);

repo.checkout(headerDataHash);
await repo.checkout(headerDataHash);
const head = repo.head();
const history = repo.getHistory();
t.equal(sumChanges(history.commits), 3, `incorrect # of changelog entries`);
Expand All @@ -38,7 +38,7 @@ test("checkout new branch with simple name", async (t) => {
await repo.commit("simple change", testAuthor);

const ref = repo.createBranch("new_feature");
repo.checkout("new_feature");
await repo.checkout("new_feature");
t.equal(repo.head(), ref, "HEAD is not moved to target branch");
});

Expand All @@ -48,7 +48,7 @@ test("checkout new branch with full ref name", async (t) => {
await repo.commit("simple change", testAuthor);

const ref = repo.createBranch("new_feature");
repo.checkout(ref);
await repo.checkout(ref);
t.equal(repo.head(), ref, "HEAD is not moved to target branch");
});

Expand All @@ -58,7 +58,7 @@ test("checkout commit which has two refs pointing leaves HEAD detached", async (
const commit = await repo.commit("simple change", testAuthor);

repo.createBranch("new_feature");
repo.checkout(commit);
await repo.checkout(commit);
t.equal(repo.ref("refs/heads/main"), commit, "main does not point to commit");
t.equal(
repo.ref("refs/heads/new_feature"),
Expand All @@ -75,14 +75,14 @@ test("checkout new branch moves head to new branch", async (t) => {
await repo.commit("simple change", testAuthor);

const ref = repo.createBranch("new_feature");
repo.checkout("new_feature");
await repo.checkout("new_feature");
t.equal(repo.head(), ref, "HEAD is not moved to target branch");
});

test("checkout and create new branch on empty main", async (t) => {
const [repo] = await getBaseline();

repo.checkout("new_feature", true);
await repo.checkout("new_feature", true);
t.equal(
repo.head(),
"refs/heads/new_feature",
Expand All @@ -96,7 +96,7 @@ test("checkout and create new branch with at least 1 commit", async (t) => {
repo.data.name = "new name";
const commit = await repo.commit("simple change", testAuthor);

repo.checkout("new_feature", true);
await repo.checkout("new_feature", true);
t.equal(
repo.head(),
"refs/heads/new_feature",
Expand All @@ -117,7 +117,7 @@ test("replacing default branch on empty master removes main", async (t) => {

// replacing default main branch by moving HEAD to new branch
// is OK even on empty repo
repo.checkout("new_feature", true);
await repo.checkout("new_feature", true);
const history = repo.getHistory();
t.equal(
sumChanges(history?.commits),
Expand All @@ -129,10 +129,7 @@ test("replacing default branch on empty master removes main", async (t) => {
repo.data.description = "description changed";
await repo.commit("description changes", testAuthor);

t.throws(
() => {
repo.checkout("main");
},
{ message: `pathspec 'main' did not match any known refs` },
);
await t.rejects(repo.checkout("main"), {
message: `pathspec 'main' did not match any known refs`,
});
});
8 changes: 4 additions & 4 deletions packages/ogre/src/commit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("changes are available for commit if starting from empty", async (t) => {
const repo = new Repository<ComplexObject>({}, {});
repo.data.name = "some data";

const dirty = repo.status();
const dirty = await repo.status();

t.equal(
dirty.length,
Expand Down Expand Up @@ -222,7 +222,7 @@ test("commit at detached HEAD does not affect main, but moves head", async (t) =
repo.data.description = "new fancy description";
const last = await repo.commit("desc change", testAuthor);

repo.checkout(commit);
await repo.checkout(commit);
t.equal(repo.head(), commit, "HEAD did not move to commit");
t.equal(repo.branch(), "HEAD", "repo is not in detached state");
t.matchOnly(v1, repo.data, "object state does not match");
Expand All @@ -243,7 +243,7 @@ test("commit at detached HEAD saved to a branch", async (t) => {
const commit = await repo.commit("name change", testAuthor);
repo.data.description = "new fancy description";
await repo.commit("desc change", testAuthor);
repo.checkout(commit);
await repo.checkout(commit);

repo.data.description = "a different description";
const commitOnDetached = await repo.commit("msg", testAuthor);
Expand All @@ -262,7 +262,7 @@ test("commit --amend changes hash on message change even in detached HEAD", asyn
const commitToAmend = await repo.commit("name change", testAuthor);
repo.data.description = "desc change";
const descCommit = await repo.commit("desc change", testAuthor);
repo.checkout(commitToAmend);
await repo.checkout(commitToAmend);
const changedHash = await repo.commit("initial setup", testAuthor, true);
t.not(changedHash, commitToAmend, "hash should have changed");
const history = repo.getHistory();
Expand Down
13 changes: 4 additions & 9 deletions packages/ogre/src/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ test("merge with no commit fails", async (t) => {

repo.createBranch("new_feature");

t.throws(
() => {
repo.merge("new_feature");
},
{ message: "already up to date" },
);
await t.rejects(repo.merge("new_feature"), { message: "already up to date" });
});

test("merge fast-forward", async (t) => {
Expand All @@ -22,7 +17,7 @@ test("merge fast-forward", async (t) => {
await repo.commit("simple change", testAuthor);
const masterCommitCount = repo.getHistory().commits.length;

repo.checkout("new_branch", true);
await repo.checkout("new_branch", true);
repo.data.name = "another name";
const minorHash = await repo.commit("minor change", testAuthor);
t.equal(
Expand All @@ -37,8 +32,8 @@ test("merge fast-forward", async (t) => {
);

// go to destination branch
repo.checkout("main");
const mergeHash = repo.merge("new_branch");
await repo.checkout("main");
const mergeHash = await repo.merge("new_branch");
const headRef = repo.head();
const refHash = repo.ref(headRef);

Expand Down
Loading

0 comments on commit f388abd

Please sign in to comment.