From 4f9d4879d7d54c442c6cc02c5386adec1ed9e0f9 Mon Sep 17 00:00:00 2001 From: Gee-Bee Date: Wed, 16 Jul 2014 10:56:58 +0200 Subject: [PATCH 1/2] Respect user details of git repo. Branch with compiled pages respects repo's user details settings. --- lib/middleman-deploy/strategies/git/base.rb | 4 +++- lib/middleman-deploy/strategies/git/force_push.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/middleman-deploy/strategies/git/base.rb b/lib/middleman-deploy/strategies/git/base.rb index cafce65..6e8dce8 100644 --- a/lib/middleman-deploy/strategies/git/base.rb +++ b/lib/middleman-deploy/strategies/git/base.rb @@ -3,13 +3,15 @@ module Middleman module Strategies module Git class Base - attr_accessor :branch, :build_dir, :remote, :commit_message + attr_accessor :branch, :build_dir, :remote, :commit_message, :user_name, :user_email def initialize(build_dir, remote, branch, commit_message) self.branch = branch self.build_dir = build_dir self.remote = remote self.commit_message = commit_message + self.user_name = `git config --get user.name` + self.user_email = `git config --get user.email` end def process diff --git a/lib/middleman-deploy/strategies/git/force_push.rb b/lib/middleman-deploy/strategies/git/force_push.rb index 786dacb..b74c061 100644 --- a/lib/middleman-deploy/strategies/git/force_push.rb +++ b/lib/middleman-deploy/strategies/git/force_push.rb @@ -20,12 +20,18 @@ module Middleman unless File.exists?('.git') `git init` `git remote add origin #{url}` + `git config user.name "#{self.user_name}"` + `git config user.name "#{self.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}` end + # check if the user name has changed + `git config user.name "#{self.user_name}"` unless self.user_name == `git config --get user.name` + # check if the remote repo has changed + `git config user.email "#{self.user_email}"` unless self.user_email == `git config --get user.email` end end From bfe647300080ab341984012a1c9d72f03bcbcb29 Mon Sep 17 00:00:00 2001 From: Gee-Bee Date: Fri, 18 Jul 2014 09:35:27 +0200 Subject: [PATCH 2/2] Fix comment. --- lib/middleman-deploy/strategies/git/force_push.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleman-deploy/strategies/git/force_push.rb b/lib/middleman-deploy/strategies/git/force_push.rb index b74c061..286ee48 100644 --- a/lib/middleman-deploy/strategies/git/force_push.rb +++ b/lib/middleman-deploy/strategies/git/force_push.rb @@ -30,7 +30,7 @@ module Middleman end # check if the user name has changed `git config user.name "#{self.user_name}"` unless self.user_name == `git config --get user.name` - # check if the remote repo has changed + # check if the user email has changed `git config user.email "#{self.user_email}"` unless self.user_email == `git config --get user.email` end end