middleman-deploy 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -58,42 +58,33 @@ Default is `false`.
58
58
 
59
59
  ### Step 4b - Git setup
60
60
 
61
- First be sure that you have already placed your project under revision
62
- control using git.
63
-
64
- For example, for the default values of remote="master" and
65
- branch="gh-pages", the output of `git branch -a` should look like:
66
-
67
- gh-pages
68
- * master
69
- remotes/origin/HEAD -> origin/master
70
- remotes/origin/gh-pages
71
- remotes/origin/master
72
-
73
- This shows that "gh-pages" exists in the remote and local repos. There
74
- needs to be at least one commit in "gh-pages" with which to start.
75
-
76
61
  Edit `config.rb`, and add:
77
62
 
78
63
  activate :deploy do |deploy|
79
64
  deploy.method = :git
80
65
  end
81
66
 
67
+ By default this will deploy to the `gh-pages` branch on the `origin`
68
+ remote. The `build` directory will become a git repo.
69
+
82
70
  #### These settings are optional.
83
71
 
84
72
  To use a particular remote, add:
85
73
 
86
74
  deploy.remote = "some-other-remote-name"
87
75
 
88
- Default is `origin`. Run `git remote -v` to see a list of possible
89
- remotes.
76
+ Default is `origin`. This can be a remote name or a git url.
77
+
78
+ If you use a remote name, you must first add it using `git remote
79
+ add`. Run `git remote -v` to see a list of possible remote names. If
80
+ you use a git url, it must end with '.git'.
90
81
 
91
82
  To use a particular branch, add:
92
83
 
93
84
  deploy.branch = "some-other-branch-name"
94
85
 
95
- Default is `gh-pages`. Run `git branch -a` to see a list of possible
96
- branches.
86
+ Default is `gh-pages`. This branch will be created on the remote if it
87
+ doesn't already exist.
97
88
 
98
89
  ### Step 4c - FTP setup
99
90
 
data/THANKS CHANGED
@@ -1,4 +1,4 @@
1
1
  Ben Cates - Git deploy method.
2
2
  Gilbert Townshend - Bug reports and feature requests.
3
3
  Konstantin Gribov -- Git deploy method improvements.
4
- Benjamin Knofe -- FTP deploy method.
4
+ Benjamin Knofe -- FTP deploy method and Git improvements.
@@ -3,8 +3,6 @@ require "middleman-core/cli"
3
3
  require "middleman-deploy/extension"
4
4
  require "middleman-deploy/pkg-info"
5
5
 
6
- require "git"
7
-
8
6
  PACKAGE = "#{Middleman::Deploy::PACKAGE}"
9
7
  VERSION = "#{Middleman::Deploy::VERSION}"
10
8
 
@@ -126,28 +124,42 @@ EOF
126
124
 
127
125
  puts "## Deploying via git to remote=\"#{remote}\" and branch=\"#{branch}\""
128
126
 
129
- # ensure that the remote branch exists in ENV["MM_ROOT"]
130
- orig = Git.open(ENV["MM_ROOT"])
131
- # TODO: orig.branch(branch, "#{remote}/#{branch}")
127
+ #check if remote is not a git url
128
+ unless remote =~ /\.git$/
129
+ remote = `git config --get remote.#{remote}.url`.chop
130
+ end
131
+
132
+ #if the remote name doesn't exist in the main repo
133
+ if remote == ''
134
+ puts "Can't deploy! Please add a remote with the name '#{self.deploy_options.remote}' to your repo."
135
+ exit
136
+ end
132
137
 
133
- Dir.mktmpdir do |tmp|
134
- # clone ENV["MM_ROOT"] to tmp (ENV["MM_ROOT"] is now "origin")
135
- repo = Git.clone(ENV["MM_ROOT"], tmp)
136
- repo.checkout("origin/#{branch}", :new_branch => branch)
138
+ Dir.chdir('build') do
139
+ unless File.exists?('.git')
140
+ `git init`
141
+ `git remote add origin #{remote}`
142
+ else
143
+ #check if the remote repo has changed
144
+ unless remote == `git config --get remote.origin.url`.chop
145
+ `git remote rm origin`
146
+ `git remote add origin #{remote}`
147
+ end
148
+ end
137
149
 
138
- # copy ./build/* to tmp
139
- FileUtils.cp_r(Dir.glob(File.join(ENV["MM_ROOT"], "build", "*")), tmp)
150
+ `git fetch origin`
140
151
 
141
- # git add and commit in tmp
142
- repo.add
143
- repo.commit("Automated commit at #{Time.now.utc} by #{PACKAGE} #{VERSION}")
152
+ #if there is a remote branch with that name, reset to it, otherwise just create a new one
153
+ if `git branch -r`.split("\n").keep_if{ |r| r =~ Regexp.new(branch,true) }.count > 0
154
+ `git reset --hard origin/#{branch}`
155
+ else
156
+ `git checkout -b #{branch}`
157
+ end
144
158
 
145
- # push back into ENV["MM_ROOT"]
146
- repo.push("origin", branch)
159
+ `git add -A`
160
+ `git commit --allow-empty -am 'Automated commit at #{Time.now.utc} by #{PACKAGE} #{VERSION}'`
161
+ `git push -f origin #{branch}`
147
162
  end
148
-
149
- orig.push(remote, branch)
150
- orig.remote(remote).fetch
151
163
  end
152
164
 
153
165
  def deploy_ftp
@@ -1,6 +1,6 @@
1
1
  module Middleman
2
2
  module Deploy
3
3
  PACKAGE = "middleman-deploy"
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
6
6
  end
@@ -21,6 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
22
22
 
23
23
  # Additional dependencies
24
- s.add_runtime_dependency("git", "~> 1.2.0")
25
24
  s.add_runtime_dependency("ptools")
26
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.0.0
30
- - !ruby/object:Gem::Dependency
31
- name: git
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.2.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.2.0
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: ptools
48
32
  requirement: !ruby/object:Gem::Requirement