Browse Source

Only add submodule if in a git repository

master
Macoy Madson 8 months ago
parent
commit
ed0bf6c8d2
  1. 36
      src/Dependencies.cake

36
src/Dependencies.cake

@ -6,22 +6,26 @@
remote-branch-name (* (const char))
&return bool)
(unless (fileExists output-directory)
(comptime-cond
('Dependencies-Clone-Only
(Logf "%s: Cloning from %s. Will NOT be tracked as a submodule\n\n"
output-directory repository-url)
(run-process-sequential-or
("git" "clone" repository-url output-directory)
(Logf "error: failed to clone %s\n" output-directory)
(return false)))
(true
(Logf "%s: Automatically adding as submodule from %s\n\n"
output-directory repository-url)
(run-process-sequential-or
("git" "submodule" "add" repository-url output-directory)
(Logf "error: failed to add %s as a git submodule dependency. Are you in a git repository?\n"
output-directory)
(return false))))
(var should-add-submodule bool
(comptime-cond ('Dependencies-Clone-Only false)
;; Don't add submodule if not in a git repository
('true (fileExists ".git"))))
(if should-add-submodule
(scope ;; Submodule
(Logf "\n%s: Automatically adding as submodule from %s\n"
output-directory repository-url)
(run-process-sequential-or
("git" "submodule" "add" repository-url output-directory)
(Logf "error: failed to add %s as a git submodule dependency. Are you in a git repository?\n"
output-directory)
(return false)))
(scope ;; Clone only
(Logf "%s: Cloning from %s. Will NOT be tracked as a submodule\n\n"
output-directory repository-url)
(run-process-sequential-or
("git" "clone" repository-url output-directory)
(Logf "error: failed to clone %s\n" output-directory)
(return false))))
(when remote-branch-name
(var remote-branch-buffer ([] 256 char) (array 0))

Loading…
Cancel
Save