Skip to content

Commit

Permalink
perf: do not resolve full git object names
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner authored and tydeu committed May 15, 2022
1 parent eef91c7 commit 85b1c0f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lake/Util/Git.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Lake.Git
def upstreamBranch :=
"master"

def isFullObjectName (rev : String) : Bool :=
rev.length == 40 && rev.all fun c => c.isDigit || ('a' <= c && c <= 'f')

def defaultRevision : Option String → String
| none => upstreamBranch
| some branch => branch
Expand Down Expand Up @@ -51,7 +54,8 @@ def parseRevision (rev : String) (repo : Option FilePath := none) : IO String :=
def headRevision (repo : Option FilePath := none) : IO String :=
parseRevision "HEAD" repo

def parseOriginRevision (rev : String) (repo : Option FilePath := none) : IO String :=
def parseOriginRevision (rev : String) (repo : Option FilePath := none) : IO String := do
if isFullObjectName rev then return rev
(parseRevision ("origin/" ++ rev) repo) <|> parseRevision rev repo
<|> throw (IO.userError s!"cannot find revision {rev} in repository {repo}")

Expand Down

0 comments on commit 85b1c0f

Please sign in to comment.