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

Gemfile #14

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'http://rubygems.org'
gemspec
51 changes: 51 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
PATH
remote: .
specs:
git-media (0.1.4)
right_aws
ruby-atmos-pure
s3
trollop

GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
git (1.2.5)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.7.5)
log4r (1.1.10)
proxies (0.2.1)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
right_aws (3.0.4)
right_http_connection (>= 1.2.5)
right_http_connection (1.3.0)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
ruby-atmos-pure (1.0.5)
log4r (>= 1.1.9)
ruby-hmac (>= 0.4.0)
ruby-hmac (0.4.0)
s3 (0.3.11)
proxies (~> 0.2.0)
trollop (2.0)

PLATFORMS
ruby

DEPENDENCIES
git-media!
jeweler
rspec
78 changes: 42 additions & 36 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ without storing the media in Git itself.

Setup the attributes filter settings.

(once after install)
$ git config filter.media.clean "git-media filter-clean"
$ git config filter.media.smudge "git-media filter-smudge"
(once after install)
$ 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.

(in repo - once)
$ echo "*.mov filter=media -crlf" > .gitattributes
(in repo - once)
$ 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.
Expand All @@ -28,72 +28,78 @@ There are four options:
2. Storing locally in a filesystem path
3. Storing remotely via SCP (should work with any SSH server)
4. Storing remotely in atmos
5. Storing remotely in Google Drive

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 = <scp|local|s3|atmos>

# settings for scp transport
scpuser=<user>
scphost=<host>
scppath=<path_on_remote_server>
[git-media]
transport = <scp|local|s3|atmos|drive>

# settings for local transport
path=<local_filesystem_path>
# settings for scp transport
scpuser=<user>
scphost=<host>
scppath=<path_on_remote_server>

# settings for s3 transport
s3bucket=<name_of_bucket>
s3key=<s3 access key>
s3secret=<s3 secret key>
# settings for local transport
path=<local_filesystem_path>

# settings for atmos transport
endpoint=<atmos server>
uid=<atmos_uid>
secret=<atmos secret key>
tag=<atmos object tag>
# settings for s3 transport
s3bucket=<name_of_bucket>
s3key=<s3 access key>
s3secret=<s3 secret key>

# settings for atmos transport
endpoint=<atmos server>
uid=<atmos_uid>
secret=<atmos secret key>
tag=<atmos object tag>

# settings for drive transport
email=<google email>
asp=<application specific password>
collection=<folder name>


== Usage

(in repo - repeatedly)
$ (hack, stage, commit)
$ git media sync
(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
$ git media status

Which will show you files that are waiting to be uploaded and how much data
that is. If you want to upload & delete the local cache of media files, run:

$ git media clear
$ git media clear

== Config Settings

$ git config --global media.auto-download false
$ git config --global media.auto-download false


== Installing
== Installing

$ sudo gem install trollop
$ sudo gem install s3
$ sudo gem install google_drive
$ 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

== Notes for Windows
It is important to switch off git smart newline character support for media files.
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
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":
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE

== Copyright

Expand Down
17 changes: 5 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,15 @@ rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rspec_opts = ['--backtrace']
end

Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end


task :default => :spec

require 'rake/rdoctask'
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
if File.exist?('VERSION.yml')
config = YAML.load(File.read('VERSION.yml'))
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.1.4
10 changes: 9 additions & 1 deletion git-media.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{git-media}
s.version = "0.1.2"
s.version = "0.1.4"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Scott Chacon"]
Expand Down Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |s|
"lib/git-media/transport/s3.rb",
"lib/git-media/transport/atmos_client.rb",
"lib/git-media/transport/scp.rb",
"lib/git-media/transport/drive.rb",
"lib/git-media/transport.rb",
"lib/git-media.rb"
]
Expand All @@ -43,6 +44,13 @@ Gem::Specification.new do |s|
s.rubygems_version = %q{1.3.1}
s.summary = %q{"This is a summary! Stop yer whining"}

s.add_dependency 'trollop'
s.add_dependency 's3'
s.add_dependency 'ruby-atmos-pure'
s.add_dependency 'right_aws'
s.add_development_dependency 'jeweler'
s.add_development_dependency 'rspec'

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
Expand Down
37 changes: 26 additions & 11 deletions lib/git-media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def self.get_media_buffer

def self.media_path(sha)
buf = self.get_media_buffer
File.join(buf, sha)
File.join(buf, sha)
end

# TODO: select the proper transports based on settings
def self.get_push_transport
self.get_transport
Expand All @@ -34,34 +34,34 @@ def self.get_transport
path = `git config git-media.scppath`.chomp
port = `git config git-media.scpport`.chomp
if user === ""
raise "git-media.scpuser not set for scp transport"
raise "git-media.scpuser not set for scp transport"
end
if host === ""
raise "git-media.scphost not set for scp transport"
raise "git-media.scphost not set for scp transport"
end
if path === ""
raise "git-media.scppath not set for scp transport"
raise "git-media.scppath not set for scp transport"
end
GitMedia::Transport::Scp.new(user, host, path, port)

when "local"
path = `git config git-media.localpath`.chomp
if path === ""
raise "git-media.localpath not set for local transport"
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
secret = `git config git-media.s3secret`.chomp
if bucket === ""
raise "git-media.s3bucket not set for s3 transport"
raise "git-media.s3bucket not set for s3 transport"
end
if key === ""
raise "git-media.s3key not set for s3 transport"
raise "git-media.s3key not set for s3 transport"
end
if secret === ""
raise "git-media.s3secret not set for s3 transport"
raise "git-media.s3secret not set for s3 transport"
end
GitMedia::Transport::S3.new(bucket, key, secret)
when "atmos"
Expand All @@ -83,6 +83,21 @@ def self.get_transport
raise "git-media.secret not set for atmos transport"
end
GitMedia::Transport::AtmosClient.new(endpoint, uid, secret, tag)
when "drive"
require 'git-media/transport/drive'
email = `git config git-media.email`.chomp
asp = `git config git-media.asp`.chomp
collection = `git config git-media.collection`.chomp
if email == ""
raise "git-media.email not set for drive transport"
end
if asp == ""
raise "git-media.asp (application specific password) not set for drive transport"
end
if collection == ""
raise "git-media.collection not set for drive transport"
end
GitMedia::Transport::Drive.new(email, asp, collection)
else
raise "Invalid transport #{transport}"
end
Expand All @@ -94,7 +109,7 @@ def self.get_pull_transport

module Application
def self.run!

cmd = ARGV.shift # get the subcommand
cmd_opts = case cmd
when "filter-clean" # parse delete options
Expand Down Expand Up @@ -125,7 +140,7 @@ def self.run!

EOF
end

end
end
end
4 changes: 2 additions & 2 deletions lib/git-media/filter-smudge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.run!
can_download = false # TODO: read this from config and implement

# read checksum size
sha = STDIN.readline(64).strip # read no more than 64 bytes
sha = STDIN.readpartial(64).lines.first.chomp # read no more than 64 bytes
if STDIN.eof? && sha.length == 40 && sha.match(/^[0-9a-fA-F]+$/) != nil
# this is a media file
media_file = File.join(media_buffer, sha.chomp)
Expand Down Expand Up @@ -35,4 +35,4 @@ def self.run!
end

end
end
end
Loading