Exemple #1
0
func BenchmarkPrepareBranchVersion(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, tCase := range btc {
			packages.PrepareBranchVersion(tCase.Branch)
		}
	}
}
Exemple #2
0
func (git *Git) prepareBranches() error {
	cmd := exec.Command("git", "branch", "--no-color", "--no-abbrev", "-v")
	cmd.Dir = git.RepoDir

	out, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("git branches --no-color --no-abbrev -v. %s", err)
	}

	for _, branch := range strings.SplitAfter(string(out), "\n") {
		response := pbRegExp.FindStringSubmatch(branch)
		if response != nil {
			git.Version = packages.PrepareBranchVersion(response[1])
			git.VersionNormalized = packages.VersionNormalizedBranch(response[1])
			git.Reference = response[2]

			p, err := git.getComposerInformation()
			if err != nil {
				return err
			}

			stability := packages.GetStability(git.Version)
			if stability != "dev" {
				p.Stability = true
			}

			git.Packages[git.Version] = p
		}
	}

	return nil
}
Exemple #3
0
func TestBranchVersion(t *testing.T) {
	for _, tc := range btc {
		v := packages.PrepareBranchVersion(tc.Branch)
		if v != tc.Version {
			t.Fatalf("PrepareBranchVersion: %s != %s", v, tc.Version)
		}

		vn := packages.VersionNormalizedBranch(tc.Branch)
		if vn != tc.VersionNormalized {
			t.Fatalf("VersionNormalizedBranch: %s != %s", vn, tc.VersionNormalized)
		}

		s := packages.GetStability(tc.Version)
		if s != tc.Stability {
			t.Fatalf("GetStability: %s != %s", s, tc.Stability)
		}
	}
}