From 10ca62b83ce0b827ea97e5367fbb3abc4ee9c0bf Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Tue, 7 Oct 2014 16:43:21 +0100 Subject: [PATCH 1/8] altered transport to include compression --- lib/git-media/sync.rb | 4 +++- lib/git-media/transport.rb | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/git-media/sync.rb b/lib/git-media/sync.rb index 866b05f..d068308 100644 --- a/lib/git-media/sync.rb +++ b/lib/git-media/sync.rb @@ -1,6 +1,7 @@ # find files that are placeholders (41 char) and download them # upload files in media buffer that are not in offsite bin require 'git-media/status' +require 'shellwords' module GitMedia module Sync @@ -35,6 +36,7 @@ def self.expand_references def self.update_index refs = GitMedia::Status.find_references + refs[:expanded] = refs[:expanded].map{ |ref| Shellwords.shellescape(ref) } `git update-index --assume-unchanged -- #{refs[:expanded].join(' ')}` puts "Updated git index" end @@ -51,4 +53,4 @@ def self.upload_local_cache end end -end \ No newline at end of file +end diff --git a/lib/git-media/transport.rb b/lib/git-media/transport.rb index f715ad9..1839282 100644 --- a/lib/git-media/transport.rb +++ b/lib/git-media/transport.rb @@ -1,19 +1,25 @@ +require 'xz' + module GitMedia module Transport class Base def pull(final_file, sha) to_file = GitMedia.media_path(sha) - get_file(sha, to_file) + to_filez = to_file + ".xz" + get_file(sha, to_filez) + XZ.decompress_file(to_filez, to_file) end def push(sha) from_file = GitMedia.media_path(sha) - put_file(sha, from_file) + from_filez = from_file + ".xz" + XZ.compress_file(from_file, from_filez) + put_file(sha, from_filez) end ## OVERWRITE ## - + def read? false end @@ -29,11 +35,11 @@ def get_file(sha, to_file) def put_file(sha, to_file) false end - + def get_unpushed(files) files end - + end end -end \ No newline at end of file +end From 769458786a2225163de3989b1044953306707b85 Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Tue, 7 Oct 2014 16:47:24 +0100 Subject: [PATCH 2/8] added compression to gemfile --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 25481dd..1132882 100644 --- a/Gemfile +++ b/Gemfile @@ -5,5 +5,6 @@ gem 's3' gem 'ruby-atmos-pure' gem 'right_aws' gem 'net_dav', :git => 'https://github.com/devrandom/net_dav.git', :require => 'net/dav' +gem 'ruby-xz' #gem 'curb', :require => false From 1485b2427eac474312086419e8658afc0cc08dd2 Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Tue, 7 Oct 2014 16:55:57 +0100 Subject: [PATCH 3/8] getting rid of some build errors for me --- Gemfile | 2 +- git-media.gemspec | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 1132882..1b9ef44 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'trollop' +gem 'trollop', '~> 2.0' gem 's3' gem 'ruby-atmos-pure' gem 'right_aws' diff --git a/git-media.gemspec b/git-media.gemspec index 3bc0fd0..8641bab 100644 --- a/git-media.gemspec +++ b/git-media.gemspec @@ -52,12 +52,12 @@ Gem::Specification.new do |s| s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, ["~> 2"]) else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2"]) end else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2"]) end end From babbffc9ab4b7b794b8255c479ebd40914695242 Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Tue, 7 Oct 2014 16:57:40 +0100 Subject: [PATCH 4/8] further silencing of warning, just assume people have modern ruby --- git-media.gemspec | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/git-media.gemspec b/git-media.gemspec index 8641bab..ef3ed4b 100644 --- a/git-media.gemspec +++ b/git-media.gemspec @@ -45,19 +45,8 @@ Gem::Specification.new do |s| ] s.homepage = "http://github.com/alebedev/git-media" s.require_paths = ["lib"] - s.rubygems_version = "1.8.28" + s.rubygems_version = "2.2.2" s.summary = "git-media" - - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, ["~> 2"]) - else - s.add_dependency(%q, ["~> 2"]) - end - else - s.add_dependency(%q, ["~> 2"]) - end + s.add_dependency(%q, ["~> 2"]) end From e9cfad8bca27f081fff903e5ba2068abf785dbed Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Wed, 8 Oct 2014 14:37:34 +0100 Subject: [PATCH 5/8] Revert "Updated install guide, not about index update" This reverts commit da746575eb4fc666f410d26b2b693ac784f0c724. --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ffa4542..ea2e199 100644 --- a/README.md +++ b/README.md @@ -82,12 +82,6 @@ that is. If you want to upload & delete the local cache of media files, run: $ git media clear -If you want to replace file in git-media with changed version (for example, video file has been edited), -you need to explicitly tell git that some media files has changed: - - $ git update-index --really-refresh - - ## Config Settings $ git config --global media.auto-download false @@ -95,10 +89,13 @@ you need to explicitly tell git that some media files has changed: ## Installing - $ sudo gem install bundler - $ bundle install + $ sudo gem install trollop + $ sudo gem install s3 + $ sudo gem install ruby-atmos-pure + $ sudo gem install right_aws + $ sudo gem install net_dav $ gem build git-media.gemspec - $ sudo gem install git-media-*.gem + $ sudo gem install git-media-0.1.3.gem ## Notes for Windows From a88522112a0d2ad3c804b85ac710c2d152d224bb Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Wed, 8 Oct 2014 14:44:20 +0100 Subject: [PATCH 6/8] nothing but shellwords --- Gemfile | 5 ++--- lib/git-media/transport.rb | 10 ++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 1b9ef44..237c9be 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,9 @@ source 'https://rubygems.org' gem 'trollop', '~> 2.0' +gem 'right_aws', :git => 'https://github.com/rightscale/right_aws.git' gem 's3' gem 'ruby-atmos-pure' -gem 'right_aws' -gem 'net_dav', :git => 'https://github.com/devrandom/net_dav.git', :require => 'net/dav' -gem 'ruby-xz' +gem 'net_dav' #gem 'curb', :require => false diff --git a/lib/git-media/transport.rb b/lib/git-media/transport.rb index 1839282..c467a65 100644 --- a/lib/git-media/transport.rb +++ b/lib/git-media/transport.rb @@ -1,21 +1,15 @@ -require 'xz' - module GitMedia module Transport class Base def pull(final_file, sha) to_file = GitMedia.media_path(sha) - to_filez = to_file + ".xz" - get_file(sha, to_filez) - XZ.decompress_file(to_filez, to_file) + get_file(sha, to_file) end def push(sha) from_file = GitMedia.media_path(sha) - from_filez = from_file + ".xz" - XZ.compress_file(from_file, from_filez) - put_file(sha, from_filez) + put_file(sha, from_file) end ## OVERWRITE ## From 97fafe3a52799ad79e3fd1eafcbfa55217208a72 Mon Sep 17 00:00:00 2001 From: ChangZong Date: Thu, 9 Oct 2014 09:52:01 +0100 Subject: [PATCH 7/8] changes to solve file names contain spaces in windows git bash. --- lib/git-media/sync.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/git-media/sync.rb b/lib/git-media/sync.rb index d068308..731035b 100644 --- a/lib/git-media/sync.rb +++ b/lib/git-media/sync.rb @@ -36,8 +36,7 @@ def self.expand_references def self.update_index refs = GitMedia::Status.find_references - refs[:expanded] = refs[:expanded].map{ |ref| Shellwords.shellescape(ref) } - `git update-index --assume-unchanged -- #{refs[:expanded].join(' ')}` + refs[:expanded].each{ |x| `git update-index --assume-unchanged -- "#{x}"`} puts "Updated git index" end From 1d5db6adf7e320c12d9c306312e018bd2981442c Mon Sep 17 00:00:00 2001 From: Duncan Paterson Date: Thu, 9 Oct 2014 10:37:55 +0100 Subject: [PATCH 8/8] remove unused import --- lib/git-media/sync.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/git-media/sync.rb b/lib/git-media/sync.rb index 731035b..d30e884 100644 --- a/lib/git-media/sync.rb +++ b/lib/git-media/sync.rb @@ -1,7 +1,6 @@ # find files that are placeholders (41 char) and download them # upload files in media buffer that are not in offsite bin require 'git-media/status' -require 'shellwords' module GitMedia module Sync