mirror of https://github.com/go-gitea/gitea
[mod]: Bump gopkg.in/src-d/go-git.v4 from 4.8.0 to 4.10.0 (#6662)
Bumps [gopkg.in/src-d/go-git.v4](https://github.com/src-d/go-git) from 4.8.0 to 4.10.0. - [Release notes](https://github.com/src-d/go-git/releases) - [Commits](https://github.com/src-d/go-git/compare/v4.8.0...v4.10.0)pull/6661/head^2
parent
62b35964e3
commit
4183c846e3
@ -0,0 +1,37 @@ |
|||||||
|
package url |
||||||
|
|
||||||
|
import ( |
||||||
|
"regexp" |
||||||
|
) |
||||||
|
|
||||||
|
var ( |
||||||
|
isSchemeRegExp = regexp.MustCompile(`^[^:]+://`) |
||||||
|
scpLikeUrlRegExp = regexp.MustCompile(`^(?:(?P<user>[^@]+)@)?(?P<host>[^:\s]+):(?:(?P<port>[0-9]{1,5})/)?(?P<path>[^\\].*)$`) |
||||||
|
) |
||||||
|
|
||||||
|
// MatchesScheme returns true if the given string matches a URL-like
|
||||||
|
// format scheme.
|
||||||
|
func MatchesScheme(url string) bool { |
||||||
|
return isSchemeRegExp.MatchString(url) |
||||||
|
} |
||||||
|
|
||||||
|
// MatchesScpLike returns true if the given string matches an SCP-like
|
||||||
|
// format scheme.
|
||||||
|
func MatchesScpLike(url string) bool { |
||||||
|
return scpLikeUrlRegExp.MatchString(url) |
||||||
|
} |
||||||
|
|
||||||
|
// FindScpLikeComponents returns the user, host, port and path of the
|
||||||
|
// given SCP-like URL.
|
||||||
|
func FindScpLikeComponents(url string) (user, host, port, path string) { |
||||||
|
m := scpLikeUrlRegExp.FindStringSubmatch(url) |
||||||
|
return m[1], m[2], m[3], m[4] |
||||||
|
} |
||||||
|
|
||||||
|
// IsLocalEndpoint returns true if the given URL string specifies a
|
||||||
|
// local file endpoint. For example, on a Linux machine,
|
||||||
|
// `/home/user/src/go-git` would match as a local endpoint, but
|
||||||
|
// `https://github.com/src-d/go-git` would not.
|
||||||
|
func IsLocalEndpoint(url string) bool { |
||||||
|
return !MatchesScheme(url) && !MatchesScpLike(url) |
||||||
|
} |
47
vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit/dotgit_setref_norwfs.go
generated
vendored
47
vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit/dotgit_setref_norwfs.go
generated
vendored
@ -1,47 +0,0 @@ |
|||||||
// +build norwfs
|
|
||||||
|
|
||||||
package dotgit |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing" |
|
||||||
) |
|
||||||
|
|
||||||
// There are some filesystems that don't support opening files in RDWD mode.
|
|
||||||
// In these filesystems the standard SetRef function can not be used as i
|
|
||||||
// reads the reference file to check that it's not modified before updating it.
|
|
||||||
//
|
|
||||||
// This version of the function writes the reference without extra checks
|
|
||||||
// making it compatible with these simple filesystems. This is usually not
|
|
||||||
// a problem as they should be accessed by only one process at a time.
|
|
||||||
func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) error { |
|
||||||
_, err := d.fs.Stat(fileName) |
|
||||||
if err == nil && old != nil { |
|
||||||
fRead, err := d.fs.Open(fileName) |
|
||||||
if err != nil { |
|
||||||
return err |
|
||||||
} |
|
||||||
|
|
||||||
ref, err := d.readReferenceFrom(fRead, old.Name().String()) |
|
||||||
fRead.Close() |
|
||||||
|
|
||||||
if err != nil { |
|
||||||
return err |
|
||||||
} |
|
||||||
|
|
||||||
if ref.Hash() != old.Hash() { |
|
||||||
return fmt.Errorf("reference has changed concurrently") |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
f, err := d.fs.Create(fileName) |
|
||||||
if err != nil { |
|
||||||
return err |
|
||||||
} |
|
||||||
|
|
||||||
defer f.Close() |
|
||||||
|
|
||||||
_, err = f.Write([]byte(content)) |
|
||||||
return err |
|
||||||
} |
|
Loading…
Reference in new issue