-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,7 @@ func NewParser(options ...Option) *Parser { | |
func (c *Parser) RepoPath(ctx context.Context, source string, head string, abbreviatedLog bool, excludedGlobs []string, isBare bool) (chan *Diff, error) { | ||
args := []string{ | ||
"-C", source, | ||
"--no-replace-objects", | ||
"log", | ||
"--patch", // https://git-scm.com/docs/git-log#Documentation/git-log.txt---patch | ||
"--full-history", | ||
|
@@ -636,28 +637,26 @@ func parseCommitLine(line []byte) (hash []byte, ref []byte) { | |
// ParseCommitSource s | ||
// https://git-scm.com/docs/git-log#Documentation/git-log.txt---source | ||
func parseSourceRef(ref []byte) string { | ||
// Remove the `refs/heads/thog` prefix. | ||
// (We don't care about refs without this prefix.) | ||
ref, ok := bytes.CutPrefix(ref, []byte("refs/heads/thog/")) | ||
if !ok { | ||
// We don't care about 'normal' refs. | ||
if bytes.HasPrefix(ref, []byte("refs/heads/")) || bytes.HasPrefix(ref, []byte("refs/tags/")) { | ||
return "" | ||
} | ||
|
||
// Handle GitHub pull requests. | ||
// e.g., `pr/238/head` or `pr/1234/merge` | ||
if after, ok := bytes.CutPrefix(ref, []byte("pr/")); ok { | ||
// e.g., `refs/pull/238/head` or `refs/pull/1234/merge` | ||
if after, ok := bytes.CutPrefix(ref, []byte("refs/pull/")); ok { | ||
prNumber := after[:bytes.Index(after, []byte("/"))] | ||
return "Pull request #" + string(prNumber) | ||
} | ||
|
||
// Handle GitLab merge requests | ||
// e.g., `mr/238/head` or `mr/1234/merge` | ||
if after, ok := bytes.CutPrefix(ref, []byte("mr/")); ok { | ||
// e.g., `refs/merge-requests/238/head` or `refs/merge-requests/1234/merge` | ||
if after, ok := bytes.CutPrefix(ref, []byte("refs/merge-requests/")); ok { | ||
mrNumber := after[:bytes.Index(after, []byte("/"))] | ||
return "Merge request #" + string(mrNumber) | ||
} | ||
|
||
return "" | ||
return fmt.Sprintf("%s (hidden ref)", string(ref)) | ||
} | ||
|
||
// Author: Bill Rich <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters