@@ -111,26 +111,37 @@ func approvalReportDesc() string {
111111
112112// listCommitsBetween list all commits that have happened between two commits in a git repo
113113func listCommitsBetween (repoRoot , oldest , newest string ) ([]string , error ) {
114- newestHash := plumbing .NewHash (newest )
115- oldestHash := plumbing .NewHash (oldest )
116114 repo , err := git .PlainOpen (repoRoot )
117115 if err != nil {
118- return []string {}, err
116+ return []string {}, fmt .Errorf ("failed to open git repository at %s: %v" ,
117+ repoRoot , err )
119118 }
120119
120+ newestHash , err := repo .ResolveRevision (plumbing .Revision (newest ))
121+ if err != nil {
122+ return []string {}, fmt .Errorf ("failed to resolve %s: %v" , newest , err )
123+ }
124+ oldestHash , err := repo .ResolveRevision (plumbing .Revision (oldest ))
125+ if err != nil {
126+ return []string {}, fmt .Errorf ("failed to resolve %s: %v" , oldest , err )
127+
128+ }
129+ log .Debugf ("This is the newest commit hash %s" , newestHash .String ())
130+ log .Debugf ("This is the oldest commit hash %s" , oldestHash .String ())
131+
121132 commits := []string {}
122133
123- commitsIter , err := repo .Log (& git.LogOptions {From : newestHash , Order : git .LogOrderCommitterTime })
134+ commitsIter , err := repo .Log (& git.LogOptions {From : * newestHash , Order : git .LogOrderCommitterTime })
124135 if err != nil {
125- return []string {}, err
136+ return []string {}, fmt . Errorf ( "failed to git log: %v" , err )
126137 }
127138
128139 for ok := true ; ok ; {
129140 commit , err := commitsIter .Next ()
130141 if err != nil {
131- return []string {}, err
142+ return []string {}, fmt . Errorf ( "failed to get next commit: %v" , err )
132143 }
133- if commit .Hash != oldestHash {
144+ if commit .Hash != * oldestHash {
134145 commits = append (commits , commit .Hash .String ())
135146 } else {
136147 break
0 commit comments