diff --git a/pkg/cmd/deploy.go b/pkg/cmd/deploy.go index de81b2a..4f65c97 100644 --- a/pkg/cmd/deploy.go +++ b/pkg/cmd/deploy.go @@ -69,6 +69,12 @@ func runDeploy( } } } + // Print CommitHash & CommitMessage + hash, msg, err := repo.GetHeadInfo(ctx) + if err != nil { + return err + } + fmt.Printf("hash: %s\nmessage: %s\n\n", hash, msg) // Set deployers deployers, err := newDeployersFunc(logger, template.New(conf.GitRevision), conf.LocalRepoPath, isucontinuous.Hosts) if err != nil { diff --git a/pkg/localrepo/localrepo.go b/pkg/localrepo/localrepo.go index 54eeae9..47b30e8 100644 --- a/pkg/localrepo/localrepo.go +++ b/pkg/localrepo/localrepo.go @@ -34,6 +34,7 @@ type LocalRepoIface interface { GetRevision(ctx context.Context) (string, error) SetRevision(ctx context.Context, revision string) error ClearRevision(ctx context.Context) error + GetHeadInfo(ctx context.Context) (string, string, error) } type LocalRepo struct { @@ -229,3 +230,17 @@ func (l *LocalRepo) SetRevision(ctx context.Context, revision string) error { func (l *LocalRepo) ClearRevision(ctx context.Context) error { return os.Remove(filepath.Join(l.absPath, revisionStoreFilename)) } + +func (l *LocalRepo) GetHeadInfo(ctx context.Context) (string, string, error) { + stdout, stderr, err := l.shell.Exec(ctx, l.absPath, "git rev-parse HEAD") + if err != nil { + return "", "", myerrors.NewErrorCommandExecutionFailed(stderr) + } + hash := stdout.String() + stdout, stderr, err = l.shell.Exec(ctx, l.absPath, "git log -1 --pretty=%B") + if err != nil { + return "", "", myerrors.NewErrorCommandExecutionFailed(stderr) + } + msg := stdout.String() + return hash, msg, nil +}