From 70ebd06a78eae3c1c72a81b3b4b6623ade5106c4 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Sun, 23 Dec 2012 15:22:29 +0100 Subject: [PATCH 01/17] The usual README-fix pull-request --- README.rdoc => README.md | 75 +++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 35 deletions(-) rename README.rdoc => README.md (62%) diff --git a/README.rdoc b/README.md similarity index 62% rename from README.rdoc rename to README.md index 94d9ae2..edfa7fd 100644 --- a/README.rdoc +++ b/README.md @@ -1,9 +1,9 @@ -= git-media +# git-media GitMedia extension allows you to use Git with large media files without storing the media in Git itself. -== Configuration +## Configuration Setup the attributes filter settings. @@ -11,14 +11,14 @@ Setup the attributes filter settings. $ git config filter.media.clean "git-media filter-clean" $ git config filter.media.smudge "git-media filter-smudge" -Setup the .gitattributes file to map extensions to the filter. +Setup the `.gitattributes` file to map extensions to the filter. (in repo - once) - $ echo "*.mov filter=media -crlf" > .gitattributes + $ echo "*.mov filter=media -crlf" > .gitattributes -Staging files with those extensions will automatically copy them to the +Staging files with those extensions will automatically copy them to the media buffer area (.git/media) until you run 'git media sync' wherein they -are uploaded. Checkouts that reference media you don't have yet will try to +are uploaded. Checkouts that reference media you don't have yet will try to be automatically downloaded, otherwise they are downloaded when you sync. Next you need to configure git to tell it where you want to store the large files. @@ -29,40 +29,41 @@ There are four options: 3. Storing remotely via SCP (should work with any SSH server) 4. Storing remotely in atmos -Here are the relevant sections that should go either in ~/.gitconfig (for global settings) -or in clone/.git/config (for per-repo settings). +Here are the relevant sections that should go either in `~/.gitconfig` (for global settings) +or in `clone/.git/config` (for per-repo settings). - [git-media] - transport = - - # settings for scp transport - scpuser= - scphost= - scppath= +```gitconfig +[git-media] + transport = - # settings for local transport - path= + # settings for scp transport + scpuser= + scphost= + scppath= - # settings for s3 transport - s3bucket= - s3key= - s3secret= + # settings for local transport + path= - # settings for atmos transport - endpoint= - uid= - secret= - tag= + # settings for s3 transport + s3bucket= + s3key= + s3secret= + # settings for atmos transport + endpoint= + uid= + secret= + tag= +``` -== Usage +## Usage (in repo - repeatedly) $ (hack, stage, commit) $ git media sync -You can also check the status of your media files via +You can also check the status of your media files via $ git media status @@ -71,12 +72,12 @@ that is. If you want to upload & delete the local cache of media files, run: $ git media clear -== Config Settings +## Config Settings $ git config --global media.auto-download false -== Installing +## Installing $ sudo gem install trollop $ sudo gem install s3 @@ -85,16 +86,20 @@ that is. If you want to upload & delete the local cache of media files, run: $ gem build git-media.gemspec $ sudo gem install git-media-0.1.1.gem -== Notes for Windows -It is important to switch off git smart newline character support for media files. -Use "-crlf" switch in .gitattributes (for example "*.mov filter=media -crlf") or config option "core.autocrlf = false". +## Notes for Windows + +It is important to switch off git smart newline character support for media files. +Use `-crlf` switch in `.gitattributes` (for example `*.mov filter=media -crlf`) or config option `core.autocrlf = false`. If installing on windows, you might run into a problem verifying certificates for S3 or something. If that happens, modify + C:\Ruby191\lib\ruby\gems\1.9.1\gems\right_http_connection-1.2.4\lib\right_http_connection.rb -And add at line 310, right before "@http.start": + +And add at line 310, right before `@http.start`: + @http.verify_mode = OpenSSL::SSL::VERIFY_NONE -== Copyright +## Copyright Copyright (c) 2009 Scott Chacon. See LICENSE for details. From e10ec9597c4dfbc9c7ba0f79c5952d9bc6b20aec Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Fri, 8 Feb 2013 15:31:28 +0000 Subject: [PATCH 02/17] quick correction on readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index edfa7fd..24a9caf 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ or in `clone/.git/config` (for per-repo settings). scppath= # settings for local transport - path= + localpath= # settings for s3 transport s3bucket= From b9a2953b626c497f5077bae7ef501dc18ca20683 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 19:23:34 +0100 Subject: [PATCH 03/17] add new entry on gemspec and copy another transport file for adaption --- git-media.gemspec | 1 + lib/git-media/transport/webdav.rb | 53 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 lib/git-media/transport/webdav.rb diff --git a/git-media.gemspec b/git-media.gemspec index 74a25c1..2c27d98 100644 --- a/git-media.gemspec +++ b/git-media.gemspec @@ -30,6 +30,7 @@ Gem::Specification.new do |s| "lib/git-media/sync.rb", "lib/git-media/transport", "lib/git-media/transport/local.rb", + "lib/git-media/transport/webdav.rb", "lib/git-media/transport/s3.rb", "lib/git-media/transport/atmos_client.rb", "lib/git-media/transport/scp.rb", diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb new file mode 100644 index 0000000..cffc572 --- /dev/null +++ b/lib/git-media/transport/webdav.rb @@ -0,0 +1,53 @@ +require 'git-media/transport' + +# move large media to local bin + +# git-media.transport wedav + +# git-media. webdav stuff + +module GitMedia + module Transport + class Webdav < Base + + def initialize(url,username,password) + @url = url + @username = username + @password = password + end + + def read? + File.exist?(@path) + end + + def get_file(sha, to_file) + from_file = File.join(@path, sha) + if File.exists?(from_file) + FileUtils.cp(from_file, to_file) + return true + end + return false + end + + def write? + File.exist?(@path) + end + + def put_file(sha, from_file) + to_file = File.join(@path, sha) + if File.exists?(from_file) + FileUtils.cp(from_file, to_file) + return true + end + return false + end + + def get_unpushed(files) + files.select do |f| + !File.exist?(File.join(@path, f)) + end + end + + end + end +end From d55532dee6159bd301f811c857ca4baa97560a22 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 20:27:11 +0100 Subject: [PATCH 04/17] convert duplicate of local transport to using webdav --- lib/git-media/transport/webdav.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index cffc572..dcef664 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -16,27 +16,34 @@ def initialize(url,username,password) @password = password end + def exist?(file) + @webdav.exists?(file) + end + def read? - File.exist?(@path) + @webdav.exists?(file) end def get_file(sha, to_file) - from_file = File.join(@path, sha) - if File.exists?(from_file) - FileUtils.cp(from_file, to_file) + dest_file = File.new(to_file, File::CREAT|File::RDWR) + if sha.exist? + @webdav.get(sha) do |stream| + dest_file.write(stream) + end + dest_file.close return true end return false end def write? - File.exist?(@path) + @webdav.exists?(file) end def put_file(sha, from_file) - to_file = File.join(@path, sha) if File.exists?(from_file) - FileUtils.cp(from_file, to_file) + File.open(from_file, r) do |stream| + @webdav.put(sha, stream, File.size(from_file)) return true end return false @@ -44,7 +51,7 @@ def put_file(sha, from_file) def get_unpushed(files) files.select do |f| - !File.exist?(File.join(@path, f)) + !File.exist?(f) end end From 311dfb3e9d194c5c2cdd54ca69e878b3e6e86879 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 20:34:56 +0100 Subject: [PATCH 05/17] add comments for required properties --- lib/git-media/transport/webdav.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index dcef664..e5daeb2 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -1,10 +1,10 @@ require 'git-media/transport' # move large media to local bin - -# git-media.transport wedav - -# git-media. webdav stuff +# git-media.transport webdav +# git-media.webdavurl +# git-media.webdavusername +# git-media.webdavpassword module GitMedia module Transport From 9db5b129ea3dafa92a43b47026597d29c8a1f808 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 20:52:06 +0100 Subject: [PATCH 06/17] add webdav require and case for properties collection/checking --- lib/git-media.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/git-media.rb b/lib/git-media.rb index 3c32810..7fd5ce9 100644 --- a/lib/git-media.rb +++ b/lib/git-media.rb @@ -1,6 +1,7 @@ require 'trollop' require 'fileutils' require 'git-media/transport/local' +require 'git-media/transport/webdav' require 'git-media/transport/s3' require 'git-media/transport/scp' @@ -44,12 +45,28 @@ def self.get_transport end GitMedia::Transport::Scp.new(user, host, path, port) + when "webdav" + user = `git config git-media.webdavusername`.chomp + if user === "" + raise "git-media.webdavusername not set for webdav transport" + end + password = `git config git-media.webdavpassword`.chomp + if password === "" + raise "git-media.webdavpassword not set for webdav transport" + end + url = `git config git-media.webdavurl`.chomp + if url === "" + raise "git-media.webdavurl not set for webdav transport" + end + GitMedia::Transport::Webdav.new(url, username, password) + when "local" path = `git config git-media.localpath`.chomp if path === "" raise "git-media.localpath not set for local transport" end GitMedia::Transport::Local.new(path) + when "s3" bucket = `git config git-media.s3bucket`.chomp key = `git config git-media.s3key`.chomp @@ -64,6 +81,7 @@ def self.get_transport raise "git-media.s3secret not set for s3 transport" end GitMedia::Transport::S3.new(bucket, key, secret) + when "atmos" require 'git-media/transport/atmos_client' endpoint = `git config git-media.endpoint`.chomp From a0a1db2ba92810785c470900654d1ef9d612401b Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 20:55:55 +0100 Subject: [PATCH 07/17] add the require for the net_dav gem! --- lib/git-media/transport/webdav.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index e5daeb2..ca82083 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -1,4 +1,5 @@ require 'git-media/transport' +require 'net/dav' # move large media to local bin # git-media.transport webdav From f808c9c45291d495a9a6c90928a53d70c9ff3f25 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sat, 7 Sep 2013 21:13:37 +0100 Subject: [PATCH 08/17] add webdav usage to readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24a9caf..e4944ca 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ or in `clone/.git/config` (for per-repo settings). ```gitconfig [git-media] - transport = + transport = # settings for scp transport scpuser= @@ -44,6 +44,11 @@ or in `clone/.git/config` (for per-repo settings). # settings for local transport localpath= + # settings for webdav transport + webdavurl= + webdavusername= + webdavpassword= + # settings for s3 transport s3bucket= s3key= @@ -80,11 +85,12 @@ that is. If you want to upload & delete the local cache of media files, run: ## Installing $ sudo gem install trollop + $ sudo gem install net_dav $ sudo gem install s3 $ sudo gem install ruby-atmos-pure $ sudo gem install right_aws $ gem build git-media.gemspec - $ sudo gem install git-media-0.1.1.gem + $ sudo gem install git-media-0.1.2.gem ## Notes for Windows From 1c3f4a31b54ac130da3cc7e64714049006aaf1c9 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sun, 8 Sep 2013 12:10:27 +0100 Subject: [PATCH 09/17] update gemspec so that it compiles add compiled gem to gitignore --- .gitignore | 1 + git-media.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 00c0b86..136fd69 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ coverage rdoc pkg +git-media-*.gem diff --git a/git-media.gemspec b/git-media.gemspec index 2c27d98..547cee7 100644 --- a/git-media.gemspec +++ b/git-media.gemspec @@ -12,13 +12,13 @@ Gem::Specification.new do |s| s.executables = ["git-media"] s.extra_rdoc_files = [ "LICENSE", - "README.rdoc" + "README.md" ] s.files = [ ".document", ".gitignore", "LICENSE", - "README.rdoc", + "README.md", "Rakefile", "VERSION", "bin/git-media", From 03968fdb30ed0448fded487eb53eeeda7eed679e Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sun, 8 Sep 2013 12:29:44 +0100 Subject: [PATCH 10/17] bit of formatting fiddling so I can find a missing end :) --- lib/git-media/transport/webdav.rb | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index ca82083..35ac43c 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -1,7 +1,7 @@ require 'git-media/transport' require 'net/dav' -# move large media to local bin +# move large media to webdav share # git-media.transport webdav # git-media.webdavurl # git-media.webdavusername @@ -13,12 +13,12 @@ class Webdav < Base def initialize(url,username,password) @url = url - @username = username - @password = password + @username = username + @password = password end def exist?(file) - @webdav.exists?(file) + @webdav.exists?(file) end def read? @@ -26,12 +26,12 @@ def read? end def get_file(sha, to_file) - dest_file = File.new(to_file, File::CREAT|File::RDWR) - if sha.exist? - @webdav.get(sha) do |stream| - dest_file.write(stream) - end - dest_file.close + dest_file = File.new(to_file, File::CREAT|File::RDWR) + if sha.exist? + @webdav.get(sha) do |stream| + dest_file.write(stream) + end + dest_file.close return true end return false @@ -44,8 +44,9 @@ def write? def put_file(sha, from_file) if File.exists?(from_file) File.open(from_file, r) do |stream| - @webdav.put(sha, stream, File.size(from_file)) - return true + @webdav.put(sha, stream, File.size(from_file)) + return true + end end return false end @@ -55,7 +56,7 @@ def get_unpushed(files) !File.exist?(f) end end - + end end -end +end \ No newline at end of file From 78664175ef39cd04a6ce1d6181c47872cee8023d Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sun, 8 Sep 2013 12:42:26 +0100 Subject: [PATCH 11/17] username, not user --- lib/git-media.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git-media.rb b/lib/git-media.rb index 7fd5ce9..3ff8bd8 100644 --- a/lib/git-media.rb +++ b/lib/git-media.rb @@ -46,8 +46,8 @@ def self.get_transport GitMedia::Transport::Scp.new(user, host, path, port) when "webdav" - user = `git config git-media.webdavusername`.chomp - if user === "" + username = `git config git-media.webdavusername`.chomp + if username === "" raise "git-media.webdavusername not set for webdav transport" end password = `git config git-media.webdavpassword`.chomp From 67f563cc77cc47fdc9edf0128eee02eba0db34ae Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Sun, 8 Sep 2013 16:16:04 +0100 Subject: [PATCH 12/17] try to correct the readme markup add quotes to the read state on file.open --- README.md | 4 ++-- lib/git-media/transport/webdav.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 86ad4b3..94705a5 100644 --- a/README.md +++ b/README.md @@ -85,12 +85,12 @@ that is. If you want to upload & delete the local cache of media files, run: ## Installing $ sudo gem install trollop - $ sudo gem install net_dav + $ sudo gem install net_dav $ sudo gem install s3 $ sudo gem install ruby-atmos-pure $ sudo gem install right_aws $ gem build git-media.gemspec - $ sudo gem install git-media-0.1.2.gem + $ sudo gem install git-media-0.1.2.gem ## Notes for Windows diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index 35ac43c..3a50dca 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -43,7 +43,7 @@ def write? def put_file(sha, from_file) if File.exists?(from_file) - File.open(from_file, r) do |stream| + File.open(from_file, "r") do |stream| @webdav.put(sha, stream, File.size(from_file)) return true end From bee6ad491e295e5ebf9410392ff3da0038fdc76f Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Mon, 9 Sep 2013 11:46:10 +0100 Subject: [PATCH 13/17] after all that, forgot to create the new connection :S --- lib/git-media/transport/webdav.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/git-media/transport/webdav.rb b/lib/git-media/transport/webdav.rb index 3a50dca..0044ac2 100644 --- a/lib/git-media/transport/webdav.rb +++ b/lib/git-media/transport/webdav.rb @@ -15,6 +15,8 @@ def initialize(url,username,password) @url = url @username = username @password = password + @webdav = Net::DAV.new(url) + @webdav.credentials(@username, @password) end def exist?(file) From 28fe94db42d4cca0a6990246c55ee3630dcc3eb4 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Mon, 9 Sep 2013 12:30:02 +0100 Subject: [PATCH 14/17] fin readme clarification for webdav usage --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 94705a5..aaccfda 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,13 @@ are uploaded. Checkouts that reference media you don't have yet will try to be automatically downloaded, otherwise they are downloaded when you sync. Next you need to configure git to tell it where you want to store the large files. -There are four options: +Here are the options: -1. Storing remotely in Amazon's S3 -2. Storing locally in a filesystem path -3. Storing remotely via SCP (should work with any SSH server) -4. Storing remotely in atmos +1. Storing locally in a filesystem path +2. Storing remotely via SCP (should work with any SSH server) +3. Storing remotely via WEBDAV (including SSL enabled servers) +4. Storing remotely in Amazon's S3 +5. Storing remotely in atmos Here are the relevant sections that should go either in `~/.gitconfig` (for global settings) or in `clone/.git/config` (for per-repo settings). @@ -61,7 +62,6 @@ or in `clone/.git/config` (for per-repo settings). tag = ``` - ## Usage (in repo - repeatedly) @@ -81,7 +81,6 @@ that is. If you want to upload & delete the local cache of media files, run: $ git config --global media.auto-download false - ## Installing $ sudo gem install trollop @@ -94,7 +93,6 @@ that is. If you want to upload & delete the local cache of media files, run: ## Notes for Windows - It is important to switch off git smart newline character support for media files. Use `-crlf` switch in `.gitattributes` (for example `*.mov filter=media -crlf`) or config option `core.autocrlf = false`. From f120c0e6589d420bb4950d088c71c9ca33abcf70 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Mon, 4 Nov 2013 11:23:42 +0000 Subject: [PATCH 15/17] add a yml file for shippable for a quick test drive --- shippable.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 shippable.yml diff --git a/shippable.yml b/shippable.yml new file mode 100644 index 0000000..e2e852b --- /dev/null +++ b/shippable.yml @@ -0,0 +1,4 @@ +language: ruby +rvm: + - 1.9.3 +script: test From 1b5894cf750188d5dbd38f257ab0c0f50e4c070c Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Mon, 4 Nov 2013 11:33:37 +0000 Subject: [PATCH 16/17] add gemfile --- Gemfile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ae2d268 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +source "https://rubygems.org" + +gem 'curb' +gem 'trollop' +gem 's3' +gem 'ruby-atmos-pure' +gem 'right_aws' +gem 'net_dav', :git => 'git://github.com/devrandom/net_dav.git', :branch => 'master' \ No newline at end of file From ad4b0c9802012b53575769ae9f583ffb57671e56 Mon Sep 17 00:00:00 2001 From: Adam Downer Date: Mon, 4 Nov 2013 11:40:00 +0000 Subject: [PATCH 17/17] edit script for shippable build --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index e2e852b..fb95f77 100644 --- a/shippable.yml +++ b/shippable.yml @@ -1,4 +1,4 @@ language: ruby rvm: - 1.9.3 -script: test +script: gem build git-media.gemspec