Skip to content
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

allow Nix builds by not calling git in isGitRepo for Nimble #23515

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions lib/std/private/gitutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal API for now, API subject to change

# xxx move other git utilities here; candidate for stdlib.

import std/[os, osproc, strutils, tempfiles]
import std/[os, paths, osproc, strutils, tempfiles]

when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
Expand Down Expand Up @@ -32,15 +32,8 @@ template retryCall*(maxRetry = 3, backoffDuration = 1.0, call: untyped): bool =
result

proc isGitRepo*(dir: string): bool =
## This command is used to get the relative path to the root of the repository.
## Using this, we can verify whether a folder is a git repository by checking
## whether the command success and if the output is empty.
let (output, status) = execCmdEx("git rev-parse --show-cdup", workingDir = dir)
# On Windows there will be a trailing newline on success, remove it.
# The value of a successful call typically won't have a whitespace (it's
# usually a series of ../), so we know that it's safe to unconditionally
# remove trailing whitespaces from the result.
result = status == 0 and output.strip() == ""
## Avoid calling git since it depends on /bin/sh existing and fails in Nix.
return fileExists(dir/".git/HEAD")

proc diffFiles*(path1, path2: string): tuple[output: string, same: bool] =
## Returns a human readable diff of files `path1`, `path2`, the exact form of
Expand Down
Loading