pages-gem icon indicating copy to clipboard operation
pages-gem copied to clipboard

Need to show a warning if Git LFS is used

Open ZiroKyl opened this issue 8 years ago • 4 comments

Before submitting an issue, please be sure to

This issue affects

  • [ ] The site generated by GitHub Pages
  • [x] Building sites locally

What did you do (e.g., steps to reproduce)

  1. jekyll new .
  2. git init .
  3. git lfs install
  4. mkdir big-user-content && cd big-user-content
    1. git lfs track '*.png'
    2. git lfs track '*.jpg'
    3. git lfs track '*.gif'
    4. cd ..
  5. add content...
  6. bundle exec jekyll serve - testing site - Ok.
  7. git add .
  8. git commit -m "Hello world"
  9. bundle exec jekyll serve - testing site, again - Ok.
  10. git remote add origin https://github.com/:user/:repo.git
  11. git push --all -u origin
  12. open https://:user.github.io/:repo/ site -> Woops, where is my images?
  13. googling:
    • git-lfs/git-lfs#791
    • git-lfs/git-lfs#1342
  14. recreate the repo...

What did you expect to happen?

  1. jekyll new .
  2. git init .
  3. git lfs install
  4. mkdir big-user-content && cd big-user-content
    1. git lfs track '*.png'
    2. git lfs track '*.jpg'
    3. git lfs track '*.gif'
    4. cd ..
  5. add content...
  6. bundle exec jekyll serve - testing site - Warning!.

What happened instead?

See "steps to reproduce".

Solutions

  • [fast] check if .git/lfs directory is exist and not empty
  • [proper] parse git lfs track and git lfs ls-files output

ZiroKyl avatar Jan 13 '18 13:01 ZiroKyl

Great idea! A little class/method to check this would be neat and help reduce confusion.

def contains_lfs_files?(site_source)
  return unless File.exist?(File.join(site_source, ".git", "lfs"))
  lfs_files = `git lfs ls-files HEAD`.strip
  return if lfs_files.empty?
  Jekyll.logger.warn "GitHub Pages:", "We detected some Git LFS files on your current ref. Git LFS is not supported by GitHub Pages, so these files will not show up on your GitHub Pages site."
end

parkr avatar Jan 14 '18 21:01 parkr

If I understand this code correctly.

The code failure if:

  • user set own lfs.storage (user have different repositories sharing the same storage directory?):
    • https://github.com/git-lfs/git-lfs/blob/739128a3fd9c7d95c96c4377f847a47596ee2c25/fs/fs.go#L24-L25
    • https://github.com/git-lfs/git-lfs/blob/v2.3.4/docs/man/git-lfs-config.5.ronn#L65-L73
    • git lfs env (see LocalMediaDir and TempDir)
  • git-lfs is not installed. git lfs ls-files HEAD output git: 'lfs' is not a git command. See 'git --help'. (output is not empty)

The code show warning only in step 9:

  1. jekyll new .
  2. git init .
  3. git lfs install
  4. mkdir big-user-content && cd big-user-content
    1. git lfs track '*.png'
    2. git lfs track '*.jpg'
    3. git lfs track '*.gif'
    4. cd ..
  5. add content...
  6. bundle exec jekyll serve - testing site - Ok.
  7. git add .
  8. git commit -m "Hello world"
  9. bundle exec jekyll serve - testing site, again - Warning!.
  10. ~~git commit --amend --no-edit~~ recreate the repo...

Solution: add additional check for git lfs track output.

ZiroKyl avatar Jan 15 '18 17:01 ZiroKyl

The code failure if:

  • git-lfs is not installed. git lfs ls-files HEAD output git: 'lfs' is not a git command. See 'git --help'. (output is not empty)

Example:

  • PC0 - git-lfs installed
  • PC1 - git-lfs not installed

PC0

  1. jekyll new a && cd a
  2. git init .
  3. add content...
  4. ...something run git lfs env (this will create .git/lfs/*)
  5. tar -C ../ -czf ../a.tar.gz a
  6. bundle exec jekyll serve - testing site - Ok.

PC1

  1. tar -xzf a.tar.gz && cd a
  2. bundle exec jekyll serve - testing site - We detected some Git LFS files on your current... :open_mouth:

ZiroKyl avatar Jan 16 '18 18:01 ZiroKyl

bump. This should be a thing. I was confused about why my website didn't load images. Also, is there a reason why pages can't support git-lfs?

alanxoc3 avatar Jun 28 '19 17:06 alanxoc3