mirror of
https://github.com/Smaug123/managed-git
synced 2025-10-08 01:08:44 +00:00
23 lines
801 B
Forth
23 lines
801 B
Forth
namespace Git.Commands
|
|
|
|
open Git
|
|
|
|
type RevParseError =
|
|
| MultipleMatches of original : string * candidates : Hash list
|
|
| Unrecognised of original : string
|
|
|
|
override this.ToString () =
|
|
match this with
|
|
| RevParseError.MultipleMatches (s, candidates) -> sprintf "fatal: ambiguous argument '%s'" s
|
|
| RevParseError.Unrecognised s ->
|
|
sprintf "fatal: ambiguous argument '%s': unknown revision or path not in the working tree." s
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module RevParse =
|
|
|
|
let rec parse (r : Repository) (s : string) : Result<Hash, RevParseError> =
|
|
match RevParse.parse r s with
|
|
| [ s ] -> Ok s
|
|
| (_ :: _ :: _) as matches -> Error (RevParseError.MultipleMatches (s, matches))
|
|
| [] -> Error (RevParseError.Unrecognised s)
|