This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 807be41  newt info: Include each repo's commit hash
807be41 is described below

commit 807be410128882c4058c9b981e000a885b656af6
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Tue Apr 16 09:25:26 2019 -0700

    newt info: Include each repo's commit hash
    
    Before commit: `newt info` displayed the version number of all repos.
    
    After commit: `newt info` displays commit hash and version number of all
    repos.
    
    This is useful for bug report submissions.
---
 newt/install/install.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/newt/install/install.go b/newt/install/install.go
index aefc530..0c08032 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -935,6 +935,7 @@ func (inst *Installer) Sync(candidates []*repo.Repo,
 
 type repoInfo struct {
        installedVer *newtutil.RepoVersion // nil if not installed.
+       commitHash   string
        errorText    string
        dirtyState   string
        needsUpgrade bool
@@ -952,6 +953,13 @@ func (inst *Installer) gatherInfo(r *repo.Repo,
                return ri
        }
 
+       commitHash, err := r.CurrentHash()
+       if err != nil {
+               ri.errorText = strings.TrimSpace(err.Error())
+               return ri
+       }
+       ri.commitHash = commitHash
+
        ver, err := detectVersion(r)
        if err != nil {
                ri.errorText = strings.TrimSpace(err.Error())
@@ -1000,6 +1008,7 @@ func (inst *Installer) Info(repos []*repo.Repo, remote 
bool) error {
                ri := inst.gatherInfo(r, vmp)
                s := fmt.Sprintf("    * %s:", r.Name())
 
+               s += fmt.Sprintf(" %s,", ri.commitHash)
                if ri.installedVer == nil {
                        s += " (not installed)"
                } else if ri.errorText != "" {

Reply via email to