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

Different results with and without installed Git #261

Open
beatcracker opened this issue Apr 6, 2023 · 4 comments
Open

Different results with and without installed Git #261

beatcracker opened this issue Apr 6, 2023 · 4 comments

Comments

@beatcracker
Copy link

I was trying to understand why I get different results while running ec in the container with mounted volume vs on host directly. In particular, it was checking binary files in the .git folder.

The culprit seems to be that under the hood ec is invoking Git to get a list of files in the repo:

This is not mentioned anywhere in the docs and no warning is issued when Git binary is not available or the command fails for other reasons.

Ideally, this has to be configurable. Something like -no-git option to preserve backward compatibility + a warning in case the Git support is enabled but fails.

I might be willing to take a stab at this if you're ok with the idea 😺 .

@polarathene
Copy link
Contributor

polarathene commented Oct 4, 2023

Something like -no-git option to preserve backward compatibility + a warning in case the Git support is enabled but fails.

git has been present in the project since Oct 2018 with version 0.0.1. Thus not really a backward compatibility concern.

If you look at the lines after your referenced one (which has an err), you'll see that it fallsback to handling when git command fails:

byteArray, err := exec.Command("git", "ls-files", "--cached", "--others", "--modified", "--exclude-standard").Output()
if err != nil {
// It is not a git repository.
cwd, err := os.Getwd()
if err != nil {
return filePaths, err
}

Prior to this there was an explicit ignore for .git/ in 0.0.1, but was replaced in 0.0.2. Probably an oversight as the ignore probably makes sense to keep, especially as a fallback.


You did not state if git was not installed on your host, but it should be clear it was in the Docker image, where your problem was presumably happening?

A newer version of git was released at some point that defaulted to some safety check which was breaking the Docker image functionality. As a result there was no implicit ignoring of .git. This was resolved in version 2.7.1.

On a host where git is not available, I imagine it'll handle the fallback scenario where it is unable to infer the git repo files under .git/ should be ignored. For that you'd want to configure an exclusion pattern, either via .ecrc.json config or the CLI --exclude option.

Here's an example, note how you need to escape the . as it's a regex pattern, so \\.git/ will do the trick:

{
  "IgnoreDefaults": false,
  "Exclude": [
    "^test/bats/",
    "^test/test_helper/bats-(assert|support)",
    "^test/test-files/",
    "\\.git/"
  ]
}

@nikolay
Copy link

nikolay commented Oct 23, 2023

@polarathene Is .ecrc.json supported as your documentation does not mention it as an alternative to .ecrc?

@polarathene
Copy link
Contributor

your documentation does not mention it as an alternative to .ecrc?

I am only marked as a contributor because I had a PR updating the README merged. Not my documentation? 😅

The project I am active on is docker-mailserver, we've been using .ecrc.json since it is json config but we explicitly provide it to the -config option, which would let you use any filename.

So no, it's probably not an officially supported filename 🤷‍♂️ Easy enough for you to check though 👍

@nikolay
Copy link

nikolay commented Oct 23, 2023

@polarathene Sorry for this! I just opened an issue. Please, upvote if you believe it will add value to the project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants