@@ -135,6 +135,15 @@ func gitVersionNewerThan(otherV string) (bool, error) {
135135// Check warns if changes introduce whitespace errors.
136136// Returns non-zero if any issues are found.
137137func Check (commit string ) ([]byte , error ) {
138+ logs , err := LogUntil (commit )
139+ if err != nil {
140+ return nil , err
141+ }
142+ if len (logs ) == 1 {
143+ logrus .Debugf ("[git.Check] %q is the initial commit. Skipping." , commit )
144+ return []byte {}, nil
145+ }
146+
138147 args := []string {
139148 "--no-pager" , "log" , "--check" ,
140149 fmt .Sprintf ("%s^..%s" , commit , commit ),
@@ -178,6 +187,21 @@ func Show(commit string) ([]byte, error) {
178187// See also FieldNames
179188type CommitEntry map [string ]string
180189
190+ // LogUntil returns the array of oneline commits from initial until the provided commit
191+ func LogUntil (commit string ) ([]string , error ) {
192+ cmd := exec .Command ("git" , "--no-pager" , "log" , "--oneline" , "--no-show-signature" , commit )
193+ if debug () {
194+ logrus .Infof ("[git] cmd: %q" , strings .Join (cmd .Args , " " ))
195+ }
196+ cmd .Stderr = os .Stderr
197+ out , err := cmd .Output ()
198+ if err != nil {
199+ logrus .Errorf ("[git] cmd: %q" , strings .Join (cmd .Args , " " ))
200+ return nil , err
201+ }
202+ return strings .Split (strings .TrimSpace (string (out )), "\n " ), nil
203+ }
204+
181205// LogCommit assembles the full information on a commit from its commit hash
182206func LogCommit (commit string ) (* CommitEntry , error ) {
183207 c := CommitEntry {}
0 commit comments