Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
coverage
rdoc
pkg
git-media-*.gem
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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'
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ 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).

```ini
```gitconfig
[git-media]
transport = <scp|local|s3|atmos>
transport = <scp|local|webdav|s3|atmos>

# settings for scp transport
scpuser = <user>
Expand All @@ -44,6 +45,11 @@ or in `clone/.git/config` (for per-repo settings).
# settings for local transport
path = <local_filesystem_path>

# settings for webdav transport
webdavurl = <webdav_url>
webdavusername = <webdav_username>
webdavpassword = <webdav_password>

# settings for s3 transport
s3bucket = <name_of_bucket>
s3key = <s3 access key>
Expand All @@ -56,7 +62,6 @@ or in `clone/.git/config` (for per-repo settings).
tag = <atmos object tag>
```


## Usage

(in repo - repeatedly)
Expand All @@ -76,15 +81,15 @@ 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
$ 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

Expand Down
5 changes: 3 additions & 2 deletions git-media.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions lib/git-media.rb
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -44,12 +45,28 @@ def self.get_transport
end
GitMedia::Transport::Scp.new(user, host, path, port)

when "webdav"
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
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
Expand All @@ -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
Expand Down
64 changes: 64 additions & 0 deletions lib/git-media/transport/webdav.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'git-media/transport'
require 'net/dav'

# move large media to webdav share
# git-media.transport webdav
# git-media.webdavurl
# git-media.webdavusername
# git-media.webdavpassword

module GitMedia
module Transport
class Webdav < Base

def initialize(url,username,password)
@url = url
@username = username
@password = password
@webdav = Net::DAV.new(url)
@webdav.credentials(@username, @password)
end

def exist?(file)
@webdav.exists?(file)
end

def read?
@webdav.exists?(file)
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
return true
end
return false
end

def write?
@webdav.exists?(file)
end

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
end
end
return false
end

def get_unpushed(files)
files.select do |f|
!File.exist?(f)
end
end

end
end
end
4 changes: 4 additions & 0 deletions shippable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: ruby
rvm:
- 1.9.3
script: gem build git-media.gemspec