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

consider ways of retrieving git status without the entire git history #157

Closed
cjyetman opened this issue Feb 22, 2024 · 7 comments
Closed
Labels

Comments

@cjyetman
Copy link
Member

#155 added back the entire git history to the Docker image to enable us to capture the git status

It would be advantageous to be able to get the git status without having to copy in the entire git history (and possibly not needing git, just parsing specific files). Some ideas towards this we're discussed in #138

Specifically, we can probably get the current git hash from just the files .git/HEAD (to get the current branch name) and .git/refs/heads/{CURRENT-BRANCH-NAME}.

git tags we don't yet have a solution for

git status should be possible with a "depth=1" clone, though it may end up confusing since we're purposefully not copying in all files (maybe we should look towards checking the git status of only specific files we want to check?)

@AlexAxthelm
Copy link
Collaborator

@cjyetman worth noting that the actions/checkout action we're using as part of the build workflow defaults to using depth=1

@cjyetman
Copy link
Member Author

confirmed that the current situation makes git status quite noisy, but additionally so because the repo is being copied into the root directory of the Docker image rather than a subdirectory (another solid reason to optimally find a way to check the git status of only specific files)...

  "git": {
    "local_git_tag": "no git tags found",
    "local_git_hash": "ee97f2649fbb47188fc64509a788ee073f93653b",
    "local_git_status": [
      {
        "status": "",
        "filename": "D .dockerignore"
      },
      {
        "status": "",
        "filename": "D .github/CODEOWNERS"
      },
      {
        "status": "",
        "filename": "D .github/workflows/add-prs-and-issues-to-project.yml"
      },
      {
        "status": "",
        "filename": "D .gitignore"
      },
      {
        "status": "",
        "filename": "D Dockerfile"
      },
      {
        "status": "",
        "filename": "M config.yml"
      },
      {
        "status": "",
        "filename": "D docker-compose.yml"
      },
      {
        "status": "",
        "filename": "D workflow.data.preparation.Rproj"
      },
      {
        "status": "??",
        "filename": ".dockerenv"
      },
      {
        "status": "??",
        "filename": ".env"
      },
      {
        "status": "??",
        "filename": "bin"
      },
      {
        "status": "??",
        "filename": "dev/"
      },
      {
        "status": "??",
        "filename": "etc/"
      },
      {
        "status": "??",
        "filename": "home/"
      },
      {
        "status": "??",
        "filename": "init"
      },
      {
        "status": "??",
        "filename": "inputs/"
      },
      {
        "status": "??",
        "filename": "lib"
      },
      {
        "status": "??",
        "filename": "lib32"
      },
      {
        "status": "??",
        "filename": "lib64"
      },
      {
        "status": "??",
        "filename": "libexec/"
      },
      {
        "status": "??",
        "filename": "libx32"
      },
      {
        "status": "??",
        "filename": "opt/"
      },
      {
        "status": "??",
        "filename": "outputs/"
      },
      {
        "status": "??",
        "filename": "proc/"
      },
      {
        "status": "??",
        "filename": "rocker_scripts/"
      },
      {
        "status": "??",
        "filename": "root/"
      },
      {
        "status": "??",
        "filename": "run/"
      },
      {
        "status": "??",
        "filename": "sbin"
      },
      {
        "status": "??",
        "filename": "sys/"
      },
      {
        "status": "??",
        "filename": "tmp/"
      },
      {
        "status": "??",
        "filename": "usr/"
      },
      {
        "status": "??",
        "filename": "var/"
      }
    ]
  },

@cjyetman
Copy link
Member Author

note that https://github.com/RMI-PACTA/pacta.data.preparation/pull/342 will at least remove all of the "untracked" files from the git status report

@AlexAxthelm
Copy link
Collaborator

A lot of our images copy to the file system root, and use that as a working directory. I'd rather get away from that (this is one reason to do so). See also: https://github.com/RMI-PACTA/pacta.data.preparation/pull/342#issuecomment-1964088016

@cjyetman
Copy link
Member Author

See also: RMI-PACTA/pacta.data.preparation#342 (comment)

This was perfect, I just couldn't figure out how to do it on my own. I think https://github.com/RMI-PACTA/pacta.data.preparation/pull/342 will resolve about 80% of this issue, but I'm gonna leave this open for now because the original intent here was to avoid having to copy in the entire git history to the Docker image.

@AlexAxthelm
Copy link
Collaborator

@cjyetman I think that once we resolve #102 and can use GH actions for image builds, the default behavior of the checkout action resolves the other 20%, in that the default behavior there is depth=1 (shallow clone).

@cjyetman
Copy link
Member Author

I've investigated the possibility of assessing the status of files without any git history, and I don't think it's possible, though it is already possible with a shallow clone, and I think that's adequate. Closing this issue.

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

No branches or pull requests

2 participants