Made the Verwion.ml more resistant.
Now in most conditions it should produce the correct commit number or an error in the rare case where a dune clean is needed.
This commit is contained in:
parent
9b1cdab3d2
commit
32c024cf4f
37
dune
37
dune
@ -28,30 +28,43 @@
|
||||
(action (copy LexerMain.exe Lexer.exe))
|
||||
(mode promote-until-clean))
|
||||
|
||||
(rule
|
||||
(targets dot_git_is_dir)
|
||||
(deps check_dot_git_is_dir.sh)
|
||||
(action (run "sh" "check_dot_git_is_dir.sh")))
|
||||
|
||||
(rule
|
||||
(targets .git_main_dir)
|
||||
(deps)
|
||||
(action (run "sh" "-c" "if test -d ../../.git; then printf %s '../../.git' > .git_main_dir; else cat ../../.git | sed -e 's/^gitdir: //' | sed -e 's|$|/../..|' > .git_main_dir; fi")))
|
||||
(deps dot_git_is_dir check_dot_git_is_dir.sh)
|
||||
(action
|
||||
(progn (run "sh" "check_dot_git_is_dir.sh")
|
||||
(run "sh" "-c" "if \"$(cat dot_git_is_dir)\" = true; then printf %s '../../.git' > .git_main_dir; else cat ../../.git | sed -e 's/^gitdir: //' | sed -e 's|$|/../..|' > .git_main_dir; fi"))))
|
||||
|
||||
(rule
|
||||
(targets .git_worktree_dir)
|
||||
(deps)
|
||||
(action (run "sh" "-c" "if test -d ../../.git; then printf %s '../../.git' > .git_worktree_dir; else cat ../../.git | sed -e 's/^gitdir: //' > .git_worktree_dir; fi")))
|
||||
(deps dot_git_is_dir check_dot_git_is_dir.sh)
|
||||
(action
|
||||
(progn (run "sh" "check_dot_git_is_dir.sh")
|
||||
(run "sh" "-c" "if \"$(cat dot_git_is_dir)\" = true; then printf %s '../../.git' > .git_worktree_dir; else cat ../../.git | sed -e 's/^gitdir: //' > .git_worktree_dir; fi"))))
|
||||
|
||||
(rule
|
||||
(targets .gitHEAD)
|
||||
(deps .git_main_dir .git_worktree_dir)
|
||||
;; TODO: re-compute .git_main_dir, just in case (since it does not have a dependency on .git)
|
||||
(action (run "sh" "-c" "ln -s \"$(cat .git_worktree_dir)/HEAD\" .gitHEAD")))
|
||||
(deps .git_main_dir .git_worktree_dir check_dot_git_is_dir.sh)
|
||||
(action
|
||||
(progn (run "sh" "check_dot_git_is_dir.sh")
|
||||
(run "sh" "-c" "ln -s \"$(cat .git_worktree_dir)/HEAD\" .gitHEAD"))))
|
||||
|
||||
(rule
|
||||
(targets Version.gitHEAD)
|
||||
(deps .gitHEAD)
|
||||
;; TODO: re-compute .git_main_dir, just in case (since it does not have a dependency on .git)
|
||||
(action (run "sh" "-c" "if git symbolic-ref HEAD >/dev/null 2>&1; then ln -s \"$(cat .git_main_dir)/$(git symbolic-ref HEAD)\" Version.gitHEAD; else ln -s \"$(cat .git_worktree_dir)/HEAD\" Version.gitHEAD; fi")))
|
||||
(deps .gitHEAD check_dot_git_is_dir.sh)
|
||||
(action
|
||||
(progn (run "sh" "check_dot_git_is_dir.sh")
|
||||
(run "sh" "-c" "if git symbolic-ref HEAD >/dev/null 2>&1; then ln -s \"$(cat .git_main_dir)/$(git symbolic-ref HEAD)\" Version.gitHEAD; else ln -s \"$(cat .git_worktree_dir)/HEAD\" Version.gitHEAD; fi"))))
|
||||
|
||||
(rule
|
||||
(targets Version.ml)
|
||||
(deps Version.gitHEAD)
|
||||
(action (run "sh" "-c" "printf 'let version = \"%s\"'\\\\n \"$(git describe --always --dirty --abbrev=0)\" > Version.ml"))
|
||||
(deps Version.gitHEAD check_dot_git_is_dir.sh)
|
||||
(action
|
||||
(progn (run "sh" "check_dot_git_is_dir.sh")
|
||||
(run "sh" "-c" "printf 'let version = \"%s\"'\\\\n \"$(git describe --always --dirty --abbrev=0)\" > Version.ml")))
|
||||
(mode promote-until-clean))
|
||||
|
Loading…
Reference in New Issue
Block a user