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

Use repository configuration of user.name and user.email for deploy commits #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions lib/octopress-deploy/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ def check_branch
end
end

# Check to see if local deployment dir is configured to deploy.
#
def check_deploy_dir
if Dir.exist? @deploy_dir
FileUtils.cd @deploy_dir do
return `git remote -v`.include? @repo
end
end
end

def self.default_config(options={})
config = <<-CONFIG
Expand All @@ -85,7 +76,9 @@ def self.default_config(options={})
# If necessary create deploy directory and initialize it with deployment remote.
#
def init_repo
return if check_deploy_dir

need_initial_commits=false

FileUtils.mkdir_p @deploy_dir
FileUtils.cd @deploy_dir do
if Dir[@deploy_dir+'/*'].empty?
Expand All @@ -100,18 +93,39 @@ def init_repo
if git_pull
`git branch -m #{@branch}`

# If no branch exists on remote, create one locally.
# If no branch exists on remote, we need to create one locally.
else
`echo "initialize deploy repo" > _`
`git add .`
`git commit -m \"initial commit\"`
`git branch -m #{@branch}`
`git rm _`
`git add -u`
`git commit -m 'cleanup'`
need_initial_commits=true
end
end
end

copy_user_config

make_initial_commits if need_initial_commits
end

def make_initial_commits
FileUtils.cd @deploy_dir do
`echo "initialize deploy repo" > _`
`git add .`
`git commit -m \"initial commit\"`
`git branch -m #{@branch}`
`git rm _`
`git add -u`
`git commit -m 'cleanup'`
end
end

# Set user config to be used for commit.
#
def copy_user_config
user_name=`git config user.name`.chomp
user_email=`git config user.email`.chomp
FileUtils.cd @deploy_dir do
`git config user.name "#{user_name}"`
`git config user.email "#{user_email}"`
end
end

def git_push
Expand Down