123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package git
- import (
- "bytes"
- "container/list"
- "path/filepath"
- "strings"
- )
- const prettyLogFormat = `--pretty=format:%H`
- func parsePrettyFormatLog(repo *Repository, logByts []byte) (*list.List, error) {
- l := list.New()
- if len(logByts) == 0 {
- return l, nil
- }
- parts := bytes.Split(logByts, []byte{'\n'})
- for _, commitId := range parts {
- commit, err := repo.GetCommit(string(commitId))
- if err != nil {
- return nil, err
- }
- l.PushBack(commit)
- }
- return l, nil
- }
- func RefEndName(refStr string) string {
- index := strings.LastIndex(refStr, "/")
- if index != -1 {
- return refStr[index+1:]
- }
- return refStr
- }
- func filepathFromSHA1(rootdir, sha1 string) string {
- return filepath.Join(rootdir, "objects", sha1[:2], sha1[2:])
- }
|