Ejemplo n.º 1
0
// StoryChanges returns the list of changes grouped by Story-Id.
func StoryChanges(stories []common.Story) ([]*StoryChangeGroup, error) {
	// Prepare the regexp to use to select commits by commit messages.
	// This regexp is ORing the chosen Story-Id tag values.
	var grepFlag bytes.Buffer
	fmt.Fprintf(&grepFlag, "^Story-Id: (%v", stories[0].Tag())
	for _, story := range stories[1:] {
		fmt.Fprintf(&grepFlag, "|%v", story.Tag())
	}
	fmt.Fprint(&grepFlag, ")$")

	// Get the relevant commits.
	commits, err := git.GrepCommitsCaseInsensitive(grepFlag.String(), "--all")
	if err != nil {
		return nil, err
	}

	okCommits := make([]*git.Commit, 0, len(commits))
	for _, commit := range commits {
		if commit.StoryIdTag == "" {
			log.Warn(fmt.Sprintf(
				"Found story commit %v, but failed to parse the Story-Id tag.", commit.SHA))
			log.NewLine("Please check that commit manually.")
			continue
		}
		okCommits = append(okCommits, commit)
	}
	commits = okCommits

	// Return the change groups.
	return StoryChangesFromCommits(commits)
}
Ejemplo n.º 2
0
func collectChanges(pattern string) ([]*changes.StoryChangeGroup, error) {
	// Collect the relevant commits.
	commits, err := git.GrepCommitsCaseInsensitive(
		fmt.Sprintf("^Story-Id: .*%v", pattern), "--all")
	if err != nil {
		return nil, err
	}

	// Group the commits.
	return changes.StoryChangesFromCommits(commits)
}
Ejemplo n.º 3
0
// StoryChanges returns the list of changes grouped by Story-Id.
func StoryChanges(stories []common.Story) ([]*StoryChangeGroup, error) {
	// Prepare the regexp to use to select commits by commit messages.
	// This regexp is ORing the chosen Story-Id tag values.
	var grepFlag bytes.Buffer
	fmt.Fprintf(&grepFlag, "^Story-Id: (%v", stories[0].Tag())
	for _, story := range stories[1:] {
		fmt.Fprintf(&grepFlag, "|%v", story.Tag())
	}
	fmt.Fprint(&grepFlag, ")$")

	// Get the relevant commits.
	commits, err := git.GrepCommitsCaseInsensitive(grepFlag.String(), "--all")
	if err != nil {
		return nil, err
	}

	// Return the change groups.
	return StoryChangesFromCommits(commits)
}