~siegfriedehret/tagzytout

afa2c743c3c035e0b7b68507952510ab3f13afb1 — Siegfried Ehret 2 years ago f006986 2.1.0
🎁 allow to use the lines after `tagzytout` for tag message

tagzytout: 2.1.0
- allow to use the lines after `tagzytout` for tag message
4 files changed, 39 insertions(+), 19 deletions(-)

M README.md
M lib/repository.go
M lib/tag.go
M main.go
M README.md => README.md +9 -0
@@ 20,6 20,15 @@ tagzytout: my-tag-name

tagzytout finds the line that starts with `tagzytout:` and extracts the following tag name, used to create a tag on that commit.

To add a message to the tag, use this:

```
tagzytout: my-tag-name
My awesome release notes:
- something
- blah
```

Then, run the tool like this in your git folder:

```bash

M lib/repository.go => lib/repository.go +27 -16
@@ 50,29 50,40 @@ func DigIntoCommits(path string) error {
	for i := len(commits) - 1; i >= 0; i-- {
		c := commits[i]

		for _, line := range strings.Split(c.Message, "\n") {
			tagzytoutIndex := strings.Index(line, prefix)

			if tagzytoutIndex == 0 {
				tagzytoutContent := strings.Trim(line[tagPrefixLength:], " ")
		foundTag := false
		tagName := ""
		tagMessage := ""

				logrus.WithFields(logrus.Fields{
					"tagzytout": tagzytoutContent,
					"commit":    c,
				}).Debug("Found a tag")
		for _, line := range strings.Split(c.Message, "\n") {
			if strings.Index(line, prefix) == 0 {
				tagName = strings.Trim(line[tagPrefixLength:], " ")
			} else if foundTag {
				tagMessage = tagMessage + "\n" + line
			}

				if err := CreateTag(r, c.Hash, tagzytoutContent, userName, userEmail); err != nil {
					logrus.WithError(err).Errorf("Failed to create tag: %s", tagzytoutContent)
				} else {
					logrus.Infof("Created tag: %s", tagzytoutContent)
				}
			if strings.Index(line, prefix) == 0 {
				foundTag = true
			}
		}

				count++
		if tagName != "" {
			logrus.WithFields(logrus.Fields{
				"tagName":    tagName,
				"tagMessage": tagMessage,
				"commit":     c,
			}).Debug("Found a tag")

			if err := CreateTag(r, c.Hash, tagName, tagMessage, userName, userEmail); err != nil {
				logrus.WithError(err).Errorf("Failed to create tag: %s", tagName)
			} else {
				logrus.Infof("Created tag: %s", tagName)
			}

			count++
		}
	}

	logrus.Infof("Found %d tags", count)

	return nil
}
\ No newline at end of file
}

M lib/tag.go => lib/tag.go +2 -2
@@ 8,10 8,10 @@ import (
	"time"
)

func CreateTag(r *git.Repository, hash plumbing.Hash, tagName, userName, userEmail string) error {
func CreateTag(r *git.Repository, hash plumbing.Hash, tagName, tagMessage, userName, userEmail string) error {
	tag := object.Tag{
		Name:    tagName,
		Message: tagName,
		Message: tagMessage,
		Tagger: object.Signature{
			Name:  userName,
			Email: userEmail,

M main.go => main.go +1 -1
@@ 10,7 10,7 @@ import (

const (
	APP     = "tagzytout v%s\n"
	VERSION = "2.0.0"
	VERSION = "2.1.0"
)

func init() {