Comments (18)
Same happening here.
# Gemfile
source "http://rubygems.org"
gem "middleman", '3.4.1'
gem "middleman-autoprefixer"
gem "middleman-deploy"
# config.rb
configure :build do
# Relative assets needed to deploy to Github Pages
activate :relative_assets
end
activate :deploy do |deploy|
deploy.build_before = true
deploy.method = :git
end
$ ruby -v -> ruby 2.2.3p173
from middleman-deploy.
I fixed this issue, by removing build directory before each deploy. For this purposes I use small extension
#lib/build_cleaner.rb
class BuildCleaner < Middleman::Extension
def initialize(app, options_hash={}, &block)
super
FileUtils.rm_rf app.config[:build_dir]
end
end
::Middleman::Extensions.register(:build_cleaner, BuildCleaner)
#config.rb
require_relative "./lib/build_cleaner"
configure :build do
activate :build_cleaner
end
from middleman-deploy.
I've done some tests and that's my experience. I hope it could help.
In root project git remote -v
gives
origin [email protected]:source/of/my/project.git
gh-pages [email protected]:username/username.github.io.git
After the first middleman build
(or first deploy
with build-before
enabled), the build directory became a git repo itself and git remote -v
gives
origin [email protected]:username/username.github.io.git
That's ok. But calling again middleman build
you can see in the output
identical build/stylesheets/site.css
identical build/images/middleman-logo.svg
identical build/javascripts/all.js
identical build/index.html
remove build/.gitignore
remove build/.git/objects/69/57aee4a38c4390d330570ae8a4989907911b56
remove build/.git/objects/2b/ecd765c79234b8662c575fac6c259ba87d033c
remove build/.git/objects/ff/d595503b2671ec3550df0b075ef60d7f535579
remove build/.git/objects/a5/e8ac2a41bdbef16c39fef16c69e4562db9c171
remove build/.git/objects/fa/2811b4915660d72191193c7bf5ef85750bbc4e
remove build/.git/objects/20/f36b5326a73789af2ff0e4464a8e80518018c3
remove build/.git/objects/98/ef9fc3abdedb871beba12bf1097e38a4a4cd48
remove build/.git/objects/7d/fde9e9fb6c498760f9c026f77bdaf778aea0a6
remove build/.git/objects/91/33babd8b3722a65e50a5514313aa65ec596019
remove build/.git/logs/refs/heads/master
remove build/.git/logs/HEAD
remove build/.git/hooks/post-update.sample
remove build/.git/hooks/pre-rebase.sample
remove build/.git/hooks/pre-push.sample
remove build/.git/hooks/update.sample
remove build/.git/hooks/pre-applypatch.sample
remove build/.git/hooks/commit-msg.sample
remove build/.git/hooks/applypatch-msg.sample
remove build/.git/hooks/prepare-commit-msg.sample
remove build/.git/hooks/pre-commit.sample
remove build/.git/index
remove build/.git/info/exclude
remove build/.git/config
remove build/.git/refs/heads/master
remove build/.git/description
remove build/.git/COMMIT_EDITMSG
remove build/.git/HEAD
Project built successfully.
Build remove all git files, but not the .git directory.
This inconsistency leads Middleman::Deploy::Strategies::Git::ForcePush::add_remote_url to produce side effects:
def add_remote_url
url = get_remote_urlunless File.exist?('.git')
git init
git remote add origin #{url}
git config user.name "#{user_name}"
git config user.email "#{user_email}"
else
# check if the remote repo has changed
unless url ==git config --get remote.origin.url
.chop
git remote rm origin
git remote add origin #{url}
# <-- Here the root project origin is overwritten!!
end
So .git data of build directory will be removed, origin of root project will be overwritten, and the root project will be pushed instead of builded one.
Infact now in root project git remote -v
gives
origin [email protected]:username/username.github.io.git
gh-pages [email protected]:username/username.github.io.git
That's why removing each time the build
directory seems to workaround.
In my opinion the build process should preserve the .git directory. Or the method above should do a more complex check process to see if remotes are ok..
from middleman-deploy.
I came here to report this very issue. I've been using middleman-deploy for years without issue, yet this recently started pushing up the entire project rather than just the build folder.
from middleman-deploy.
same problem here. it does push all project, not build folder. (2.0.0 alpha)
from middleman-deploy.
In case you need temporary quick fix, middleman deploy
works if there are no files on the master branch.
I work from development branch so this is what works for me:
git checkout master && sudo rm -r Gemfile.lock build && git checkout development && middleman deploy
YMMV though
from middleman-deploy.
Hmm, this appears to be a git issue. I tried locking all old versions of middleman and it's nothing there.
from middleman-deploy.
Guys, I forked jekyll-github-deploy into https://github.com/hovancik/middleman-github-deploy, you might wanna check it out. For now it solved problem with middleman-deploy. It's a bit different approach, but you can easy deploy your site to GithubPages with it. Works for me.
from middleman-deploy.
@robinbortlik I've found that your solution of deleting the build directory also is working for me. Where did you put this require in your config? I'm not sure when or why this started happening as everything was working fine for me about a week ago and I haven't changed anything that I know of since then.
from middleman-deploy.
@robinbortlik 's fix worked for me. Any chance we can get this behavior as a default in middleman-deploy?
from middleman-deploy.
@christopherjanzen @JustinHardage I'm glad that it helped. I put my require at the top of config.rb
file. I also have no explanation why it stopped working. But I don't think, it should be included in the middleman deploy. This is more a hotfix. The reason why middleman don't delete whole build folder is to speedup build process. I guess. :)
from middleman-deploy.
Also stumbled into this, thought I was going mad initially, so thanks for posting!
The fix/tweak above resolves for me under mint/2.2.2 and git 1.9.1.
HTH.
from middleman-deploy.
Deleting build directory before each deploy made this work for me. Not sure what needs to be done to get this fixed.
from middleman-deploy.
However this implementation of Middleman::Deploy::Strategies::Git::ForcePush::add_remote_url will regenerate .git
data every time. Maybe it's a better solution than cleaning the entire build
directory.
def add_remote_url
url = get_remote_url
`git init`
`git remote add origin #{url}`
`git config user.name "#{user_name}"`
`git config user.email "#{user_email}"`
end
from middleman-deploy.
The issue isn't with middleman-deploy or git so much as it is with middleman v4 which changed the build process. v4.1.0.rc.2 includes a config directive to change this behavior and resolve the above problem. See middleman/middleman#1716 for the full details.
I don't use middleman-deploy and still had this issue, for what it's worth (I've been using https://github.com/edgecase/middleman-gh-pages successfully for a long while).
configure :deploy do
set :skip_build_clean do |path|
path =~ /\.git/
end
end
from middleman-deploy.
Experiencing the same behavior with my Middleman 4 project.
from middleman-deploy.
I used @egardner patch and it worked! Thanks!
from middleman-deploy.
@coreyward 's information solved my Middeman v4.1 project's issue. Thank you!
from middleman-deploy.
Related Issues (20)
- README: 'deploy_method' should be 'deploy' HOT 5
- Local changes would be overwritten by checkout
- CNAME gets blown out with force update HOT 4
- `block in initialize': undefined method `deploy_method=' for #<Middleman::Deploy
- Can't deploy to remote HOT 1
- Deploy build directory to github pages? HOT 7
- undefined method "deploy_method" HOT 7
- Compatibility with Middleman 4.1.7 HOT 4
- Deploy path doesn't work for Git Deploy Method HOT 1
- Rsync: Configured username ignored HOT 4
- Forceful deploy cause long upload times
- deploy.user not being set HOT 1
- Error with Middleman 4.2 and middleman-deploy 1.0 HOT 16
- deploy.deploy_method has changed to method HOT 1
- How to deploy robots.txt file HOT 1
- Ubuntu 18.04 rsync method fails
- Support additional commands during deploy
- Feature Request: support a different trunk branch HOT 1
- Is this gem abandoned? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from middleman-deploy.