String is equivalent to `git submodule status ` This will print the SHA-1 of the currently checked out commit for a submodule, along with the submodule path and the output of git describe fo the SHA-1. Each SHA-1 will be prefixed with - if the submodule is not initialized, + if the curre
()
| 375 | // initialized, + if the currently checked out submodule commit does not match |
| 376 | // the SHA-1 found in the index of the containing repository. |
| 377 | func (s *SubmoduleStatus) String() string { |
| 378 | var extra string |
| 379 | var status = ' ' |
| 380 | |
| 381 | if s.Current.IsZero() { |
| 382 | status = '-' |
| 383 | } else if !s.IsClean() { |
| 384 | status = '+' |
| 385 | } |
| 386 | |
| 387 | if len(s.Branch) != 0 { |
| 388 | extra = string(s.Branch[5:]) |
| 389 | } else if !s.Current.IsZero() { |
| 390 | extra = s.Current.String()[:7] |
| 391 | } |
| 392 | |
| 393 | if extra != "" { |
| 394 | extra = fmt.Sprintf(" (%s)", extra) |
| 395 | } |
| 396 | |
| 397 | return fmt.Sprintf("%c%s %s%s", status, s.Expected, s.Path, extra) |
| 398 | } |