mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-01 15:19:09 +01:00
c05a8abc76
* Multiple GitGraph improvements. Add backend support for excluding PRs, selecting branches and files. Fix #10327 Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> * Only show refs in dropdown we display on the graph Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> * use flexbox for ui header Signed-off-by: Andrew Thornton <art27@cantab.net> * Move Hide Pull Request button to the dropdown Signed-off-by: Andrew Thornton <art27@cantab.net> * Add SHA and user pictures Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test 2 Signed-off-by: Andrew Thornton <art27@cantab.net> * fixes * async * more tweaks * use tabs in tmpl Signed-off-by: Andrew Thornton <art27@cantab.net> * remove commented thing Signed-off-by: Andrew Thornton <art27@cantab.net> * fix linting Signed-off-by: Andrew Thornton <art27@cantab.net> * Update web_src/js/features/gitgraph.js Co-authored-by: silverwind <me@silverwind.io> * graph tweaks * more tweaks * add title Signed-off-by: Andrew Thornton <art27@cantab.net> * fix loading indicator z-index and position Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package git
|
|
|
|
import "strings"
|
|
|
|
// Reference represents a Git ref.
|
|
type Reference struct {
|
|
Name string
|
|
repo *Repository
|
|
Object SHA1 // The id of this commit object
|
|
Type string
|
|
}
|
|
|
|
// Commit return the commit of the reference
|
|
func (ref *Reference) Commit() (*Commit, error) {
|
|
return ref.repo.getCommit(ref.Object)
|
|
}
|
|
|
|
// ShortName returns the short name of the reference
|
|
func (ref *Reference) ShortName() string {
|
|
if ref == nil {
|
|
return ""
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/heads/") {
|
|
return ref.Name[11:]
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/tags/") {
|
|
return ref.Name[10:]
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/remotes/") {
|
|
return ref.Name[13:]
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/pull/") && strings.IndexByte(ref.Name[10:], '/') > -1 {
|
|
return ref.Name[10 : strings.IndexByte(ref.Name[10:], '/')+10]
|
|
}
|
|
|
|
return ref.Name
|
|
}
|
|
|
|
// RefGroup returns the group type of the reference
|
|
func (ref *Reference) RefGroup() string {
|
|
if ref == nil {
|
|
return ""
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/heads/") {
|
|
return "heads"
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/tags/") {
|
|
return "tags"
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/remotes/") {
|
|
return "remotes"
|
|
}
|
|
if strings.HasPrefix(ref.Name, "refs/pull/") && strings.IndexByte(ref.Name[10:], '/') > -1 {
|
|
return "pull"
|
|
}
|
|
return ""
|
|
}
|