Skip to content

Commit

Permalink
fix(versioning): resolveVersion should not call getTreeVersion
Browse files Browse the repository at this point in the history
*facepalm*
  • Loading branch information
edvald committed Jul 16, 2018
1 parent 4fa78ee commit 91ae14f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/vcs/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export abstract class VcsHandler {
}

async resolveVersion(module: Module, dependencies: Module[]): Promise<ModuleVersion> {
const treeVersion = await this.getTreeVersion([module.path])
const treeVersion = await this.resolveTreeVersion(module)

validate(treeVersion, treeVersionSchema, { context: `${this.name} tree version for module at ${module.path}` })

Expand Down
39 changes: 8 additions & 31 deletions test/src/vcs/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ describe("VcsHandler", () => {
let handler: TestVcsHandler
let ctx: PluginContext

// note: module-a has a version file with this content
const versionA = {
latestCommit: "1234567890",
dirtyTimestamp: null,
}

beforeEach(async () => {
handler = new TestVcsHandler(projectRootA)
ctx = await makeTestContextA()
Expand Down Expand Up @@ -56,25 +62,18 @@ describe("VcsHandler", () => {
describe("resolveVersion", () => {
it("should return module version if there are no dependencies", async () => {
const module = await ctx.getModule("module-a")
const versionString = "abcdef"
const version = {
latestCommit: versionString,
dirtyTimestamp: null,
}

handler.setTestVersion(module.path, version)

const result = await handler.resolveVersion(module, [])

expect(result).to.eql({
versionString,
versionString: versionA.latestCommit,
dirtyTimestamp: null,
dependencyVersions: {},
})
})

it("should return module version if there are no dependencies and properly handle a dirty timestamp", async () => {
const module = await ctx.getModule("module-a")
const module = await ctx.getModule("module-b")
const latestCommit = "abcdef"
const version = {
latestCommit,
Expand All @@ -95,12 +94,6 @@ describe("VcsHandler", () => {
it("should return the dirty version if there is a single one", async () => {
const [moduleA, moduleB, moduleC] = await ctx.getModules(["module-a", "module-b", "module-c"])

// note: module-a has a version file
const versionA = {
latestCommit: "1234567890",
dirtyTimestamp: null,
}

const versionB = {
latestCommit: "qwerty",
dirtyTimestamp: null,
Expand All @@ -127,12 +120,6 @@ describe("VcsHandler", () => {
it("should return the latest dirty version if there are multiple", async () => {
const [moduleA, moduleB, moduleC] = await ctx.getModules(["module-a", "module-b", "module-c"])

// note: module-a has a version file
const versionA = {
latestCommit: "1234567890",
dirtyTimestamp: null,
}

const versionB = {
latestCommit: "qwerty",
dirtyTimestamp: 456,
Expand All @@ -159,11 +146,6 @@ describe("VcsHandler", () => {
it("should hash together the version of the module and all dependencies if none are dirty", async () => {
const [moduleA, moduleB, moduleC] = await ctx.getModules(["module-a", "module-b", "module-c"])

const versionA = {
latestCommit: "1234567890",
dirtyTimestamp: null,
}

const versionStringB = "qwerty"
const versionB = {
latestCommit: versionStringB,
Expand Down Expand Up @@ -194,11 +176,6 @@ describe("VcsHandler", () => {

const [moduleA, moduleB, moduleC] = await ctx.getModules(["module-a", "module-b", "module-c"])

const versionA = {
latestCommit: "1234567890",
dirtyTimestamp: null,
}

const versionStringB = "qwerty"
const versionB = {
latestCommit: versionStringB,
Expand Down

0 comments on commit 91ae14f

Please sign in to comment.