コード例 #1
0
func (bump PreBump) Apply(v semver.Version) semver.Version {
	if v.Pre == nil || v.Pre[0].VersionStr != bump.Pre {
		v.Pre = []semver.PRVersion{
			{VersionStr: bump.Pre},
			{VersionNum: 1, IsNum: true},
		}
	} else {
		v.Pre = []semver.PRVersion{
			{VersionStr: bump.Pre},
			{VersionNum: v.Pre[1].VersionNum + 1, IsNum: true},
		}
	}

	return v
}
コード例 #2
0
			Major: 1,
			Minor: 2,
			Patch: 3,
		}

		bump = version.PreBump{}
	})

	JustBeforeEach(func() {
		outputVersion = bump.Apply(inputVersion)
	})

	Context("when the version is a prerelease", func() {
		BeforeEach(func() {
			inputVersion.Pre = []semver.PRVersion{
				{VersionStr: "alpha"},
				{VersionNum: 1, IsNum: true},
			}
		})

		Context("when the bump is the same prerelease type", func() {
			BeforeEach(func() {
				bump.Pre = "alpha"
			})

			It("bumps the prerelease version number", func() {
				Expect(outputVersion).To(Equal(semver.Version{
					Major: 1,
					Minor: 2,
					Patch: 3,
					Pre: []semver.PRVersion{
						{VersionStr: "alpha"},
コード例 #3
0
func (MinorBump) Apply(v semver.Version) semver.Version {
	v.Minor++
	v.Patch = 0
	v.Pre = nil
	return v
}
コード例 #4
0
func (FinalBump) Apply(v semver.Version) semver.Version {
	v.Pre = nil
	return v
}
コード例 #5
0
			Context(fmt.Sprintf("when bumping %s", bumpLocal), func() {
				BeforeEach(func() {
					bumpParam = bumpLocal
				})

				It("bumps to "+resultLocal, func() {
					Ω(version.String()).Should(Equal(resultLocal))
				})
			})
		}

		Context("when it's already a prerelease", func() {
			BeforeEach(func() {
				version.Pre = []semver.PRVersion{
					{VersionStr: "rc"},
					{VersionNum: 1, IsNum: true},
				}
			})

			for bump, result := range map[string]string{
				"":      "1.2.3-rc.2",
				"final": "1.2.3-rc.1",
				"patch": "1.2.4-rc.1",
				"minor": "1.3.0-rc.1",
				"major": "2.0.0-rc.1",
			} {
				bumpLocal := bump
				resultLocal := result

				Context(fmt.Sprintf("when bumping %s", bumpLocal), func() {
					BeforeEach(func() {
コード例 #6
0
func (PatchBump) Apply(v semver.Version) semver.Version {
	v.Patch++
	v.Pre = nil
	return v
}