git-fyncy 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +48 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/bin/git-fyncy +4 -0
- data/git-fyncy.gemspec +25 -0
- data/lib/git-fyncy/version.rb +3 -0
- data/lib/git-fyncy.rb +69 -0
- metadata +80 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p385"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.18.6 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ryan McGowan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# git-fyncy
|
2
|
+
|
3
|
+
The funky git aware remote syncer.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'git-fyncy'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install git-fyncy
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Sync the current working directory to the given path on the given remote:
|
22
|
+
|
23
|
+
$ git fyncy <remote> <path>
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/git-fyncy
ADDED
data/git-fyncy.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'git-fyncy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "git-fyncy"
|
8
|
+
gem.version = GitFyncy::VERSION
|
9
|
+
gem.authors = ["Ryan McGowan"]
|
10
|
+
gem.email = ["ryan@ryanmcg.com"]
|
11
|
+
gem.description = %q{The funky git aware syncer.}
|
12
|
+
gem.summary = %q{Want to sync the working directories of your git
|
13
|
+
directory with a remote one. Look no futher.}
|
14
|
+
gem.homepage = "https://github.com/RyanMcG/git-fyncy"
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
[['listen', '~> 1.3']].each do |dep|
|
23
|
+
gem.add_dependency(*dep)
|
24
|
+
end
|
25
|
+
end
|
data/lib/git-fyncy.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "git-fyncy/version"
|
2
|
+
require 'listen'
|
3
|
+
|
4
|
+
module GitFyncy
|
5
|
+
def self.slashify(path)
|
6
|
+
path[-1] == '/' ? path : path + '/'
|
7
|
+
end
|
8
|
+
|
9
|
+
RELATIVE_PATH = slashify `pwd`.rstrip
|
10
|
+
|
11
|
+
class Remote
|
12
|
+
def initialize(remote, path)
|
13
|
+
@remote = remote
|
14
|
+
@path = GitFyncy.slashify path
|
15
|
+
end
|
16
|
+
|
17
|
+
def command(cmd)
|
18
|
+
puts cmd
|
19
|
+
system cmd
|
20
|
+
end
|
21
|
+
|
22
|
+
def scp(paths)
|
23
|
+
return if paths.empty?
|
24
|
+
command "rsync -zR #{paths.to_a.join ' '} #{@remote}:#{@path}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def ssh_rm(paths)
|
28
|
+
return if paths.empty?
|
29
|
+
command "ssh #{@remote} 'cd #{@path}; rm -f #{paths.to_a.join ' '}'"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.relative_path(path)
|
34
|
+
path.slice! RELATIVE_PATH
|
35
|
+
path
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.git_aware_files
|
39
|
+
`git ls-files -mo --exclude-standard`.split("\n")
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.git_aware_of_path?(path)
|
43
|
+
self.git_aware_files.include? path
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.pexit(error)
|
47
|
+
puts error
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.main(remote, path)
|
52
|
+
pexit 'A remote and path must be specified' unless remote && path
|
53
|
+
remote = Remote.new remote, path
|
54
|
+
remote.scp git_aware_files
|
55
|
+
relpath = method :relative_path
|
56
|
+
|
57
|
+
files_to_remove = Set.new
|
58
|
+
Listen.to!('.') do |modified, added, removed|
|
59
|
+
begin
|
60
|
+
remote.scp git_aware_files
|
61
|
+
rel_removed = removed.map(&relpath)
|
62
|
+
files_to_remove.merge rel_removed
|
63
|
+
files_to_remove.clear if remote.ssh_rm files_to_remove
|
64
|
+
rescue => e
|
65
|
+
puts e.inspect
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-fyncy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan McGowan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: listen
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
description: The funky git aware syncer.
|
31
|
+
email:
|
32
|
+
- ryan@ryanmcg.com
|
33
|
+
executables:
|
34
|
+
- git-fyncy
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- .rvmrc
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/git-fyncy
|
45
|
+
- git-fyncy.gemspec
|
46
|
+
- lib/git-fyncy.rb
|
47
|
+
- lib/git-fyncy/version.rb
|
48
|
+
homepage: https://github.com/RyanMcG/git-fyncy
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
hash: -4174756479981268395
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: -4174756479981268395
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.23
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Want to sync the working directories of your git directory with a remote
|
79
|
+
one. Look no futher.
|
80
|
+
test_files: []
|