-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: mk_all ignores locally removed files #11850
Conversation
Maybe this could be a flag to the command? Namely I also wonder whether we could write the script in Lean so that any downstream project can create their all file as |
I can easily implement the flag. As for writing the function in Lean, this is a first possibility: def mkAll (mathlib : String := "Mathlib") : IO Unit := do
let pth ← System.FilePath.walkDir mathlib
let files := (pth.filter (·.extension == some "lean")).qsort (·.toString < ·.toString)
let withImport ← files.mapM fun f => do
return "import " ++ (← Lean.moduleNameOfFileName f none).toString
IO.FS.writeFile (mathlib ++ ".lean") (String.intercalate "\n" withImport.toList) After that, running However, all really means all (.lean) files in the EDIT: this is a way of getting def gitLSFiles : IO.Process.SpawnArgs where
cmd := "git"
args := #["ls-files", "*.lean"]
open Lean System.FilePath in
def mkAll (ml : String := "Mathlib") : IO Unit := do
let ml.lean := addExtension ⟨ml⟩ "lean" -- `Mathlib.lean`
let mlDir := ml.push pathSeparator -- `Mathlib/`
let allLean ← IO.Process.run gitLSFiles
let files : List System.FilePath := ((allLean.splitOn "\n").filter mlDir.isPrefixOf).map (⟨·⟩)
let files := (files.erase ml.lean).toArray.qsort (·.toString < ·.toString)
let withImport ← files.mapM fun f => return "import " ++ (← moduleNameOfFileName f none).toString
IO.FS.writeFile ml.lean <| ("\n".intercalate withImport.toList).push '\n' |
Given that Lean libraries aren't necessarily backed by a git repository, so I think not using the information from git is the correct default behaviour. You could recover the current behaviour by adding a |
I am implementing the simple version of the -- use git
run_cmd mkAll (git? := true) (cands := candidates)
-- recurse into dirs
run_cmd mkAll (git? := false) (cands := candidates) (The argument are actually not optional, but the explicit labels make them clearer, I hope!) |
Let's mark this as blocked on #11853 (which has been approved, but not yet merged) --- that PR would certainly fix the issue this is solving. |
I believe this PR could simply be closed since we will soon remove |
Since #11853 has landed, this PR can be closed, right? |
I think we should just delete |
@YaelDillies should I If you are ok with closing, feel free to do so yourself as well! |
Yes, let's close this PR |
@YaelDillies pointed out that their preference was to exclude files that are removed, but not yet staged.
From the point of view of CI, the change should be invisible, since CI acts on an unmodified branch.