pages-gem
pages-gem copied to clipboard
Need to show a warning if Git LFS is used
Before submitting an issue, please be sure to
- [x] Read the contributing instructions
- [x] Update to the latest Gem version (run
bundle update github-pages)
This issue affects
- [ ] The site generated by GitHub Pages
- [x] Building sites locally
What did you do (e.g., steps to reproduce)
-
jekyll new . -
git init . -
git lfs install -
mkdir big-user-content && cd big-user-content-
git lfs track '*.png' -
git lfs track '*.jpg' -
git lfs track '*.gif' -
cd ..
-
- add content...
-
bundle exec jekyll serve- testing site - Ok. -
git add . -
git commit -m "Hello world" -
bundle exec jekyll serve- testing site, again - Ok. -
git remote add origin https://github.com/:user/:repo.git -
git push --all -u origin - open
https://:user.github.io/:repo/site -> Woops, where is my images? - googling:
- git-lfs/git-lfs#791
- git-lfs/git-lfs#1342
- recreate the repo...
What did you expect to happen?
-
jekyll new . -
git init . -
git lfs install -
mkdir big-user-content && cd big-user-content-
git lfs track '*.png' -
git lfs track '*.jpg' -
git lfs track '*.gif' -
cd ..
-
- add content...
-
bundle exec jekyll serve- testing site - Warning!.
What happened instead?
See "steps to reproduce".
Solutions
- [fast] check if
.git/lfsdirectory is exist and not empty - [proper] parse
git lfs trackandgit lfs ls-filesoutput
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
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(seeLocalMediaDirandTempDir)
- git-lfs is not installed.
git lfs ls-files HEADoutputgit: 'lfs' is not a git command. See 'git --help'.(output is not empty)
The code show warning only in step 9:
-
jekyll new . -
git init . -
git lfs install -
mkdir big-user-content && cd big-user-content-
git lfs track '*.png' -
git lfs track '*.jpg' -
git lfs track '*.gif' -
cd ..
-
- add content...
-
bundle exec jekyll serve- testing site - Ok. -
git add . -
git commit -m "Hello world" -
bundle exec jekyll serve- testing site, again - Warning!. - ~~
git commit --amend --no-edit~~ recreate the repo...
Solution: add additional check for git lfs track output.
The code failure if:
- git-lfs is not installed.
git lfs ls-files HEADoutputgit: 'lfs' is not a git command. See 'git --help'.(output is not empty)
Example:
- PC0 - git-lfs installed
- PC1 - git-lfs not installed
PC0
-
jekyll new a && cd a -
git init . - add content...
- ...something run
git lfs env(this will create.git/lfs/*) -
tar -C ../ -czf ../a.tar.gz a -
bundle exec jekyll serve- testing site - Ok.
PC1
-
tar -xzf a.tar.gz && cd a -
bundle exec jekyll serve- testing site - We detected some Git LFS files on your current... :open_mouth:
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?