git_flo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +12 -0
- data/README.md +72 -0
- data/Rakefile +15 -0
- data/git_flo.gemspec +30 -0
- data/lib/flo/provider/git_flo.rb +70 -0
- data/lib/git_flo/version.rb +8 -0
- data/lib/git_flo.rb +10 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3753d587294f1d4ee16688be1a420d10ce1244eb
|
4
|
+
data.tar.gz: 979bb2260edac4ebae81513a23e5e94f7e9ab9da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84c501538a113bf12d667bc80861e906f171e39c09fe1b16b9b3f8ceba6618ab8fef908a416801c648c610c6d5331d62e99a9204a99abb33d9fed1ad61636f27
|
7
|
+
data.tar.gz: a1b092f2b31e05cea7f567251148c06647ecb610cf14fc16034b6499c04df1ee24087981926b923b3ab0dc94be5209ead13ca9ef3b82ed97c0d14eacb0866dc6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
# Licensed under the BSD 3-Clause license.
|
4
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
5
|
+
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
|
8
|
+
# Specify your gem's dependencies in git_flo.gemspec
|
9
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Copyright (c) 2017, Salesforce.com, Inc.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
9
|
+
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# GitFlo
|
2
|
+
|
3
|
+
GitFlo is a Git plugin for the Flo workflow automation library. If you aren't familiar with Flo, then please start [here](https://github.com/salesforce/flo)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'git_flo'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install git_flo
|
20
|
+
|
21
|
+
## Compatibility
|
22
|
+
|
23
|
+
GitFlo uses the Rugged rubygem, which includes C bindings to the libgit2 C library. For this reason, this gem is not expected to work with jruby. For more information on Rugged, [check it out on Github](https://github.com/libgit2/rugged)
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
In your Flo configuration file, configure git inside the `config` block
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config do |cfg|
|
31
|
+
cfg.provider :git_flo, { credentials: Rugged::Credentials::SshKeyFromAgent.new(username: 'git') }
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
If you will not be running flo within your local git repository, you can pass in a `:repo_location` option to specify where the git repo exists.
|
36
|
+
|
37
|
+
If you wish to push to a repo requiring authentication, you must specify a `credentials` provider. See the [Rugged::Credentials module](https://github.com/libgit2/rugged/blob/master/lib/rugged/credentials.rb) for options.
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Specify the commands you wish to run in the `register_command` block. For example
|
42
|
+
```ruby
|
43
|
+
# Checks out a branch with the name "my_new_branch". If the branch does not exist, a new branch is created based off the master branch
|
44
|
+
perform :git_flo, :check_out_or_create_branch, { from: 'master', name: 'my_new_branch' }
|
45
|
+
|
46
|
+
# pushes the 'my_new_branch' up to the 'origin' remote repo. This will raise an error if this would result in a force push
|
47
|
+
perform :git_flo, :push, { branch: 'my_new_branch' }
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it (http://github.com/your-github-username/flo/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
>Copyright (c) 2017, Salesforce.com, Inc.
|
62
|
+
>All rights reserved.
|
63
|
+
>
|
64
|
+
>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
65
|
+
>
|
66
|
+
>* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
67
|
+
>
|
68
|
+
>* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
69
|
+
>
|
70
|
+
>* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
71
|
+
>
|
72
|
+
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
# Licensed under the BSD 3-Clause license.
|
4
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
5
|
+
|
6
|
+
require "bundler/gem_tasks"
|
7
|
+
require "rake/testtask"
|
8
|
+
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << "test"
|
11
|
+
t.libs << "lib"
|
12
|
+
t.test_files = FileList['test/**/*_test.rb']
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :test
|
data/git_flo.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
3
|
+
# All Rights Reserved.
|
4
|
+
# Licensed under the BSD 3-Clause license.
|
5
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
6
|
+
|
7
|
+
lib = File.expand_path('../lib', __FILE__)
|
8
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
9
|
+
require 'git_flo/version'
|
10
|
+
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
spec.name = "git_flo"
|
13
|
+
spec.version = GitFlo::VERSION
|
14
|
+
spec.authors = ['Justin Powers', 'John Tuley']
|
15
|
+
spec.email = ['justin.powers@salesforce.com', 'jtuley@salesforce.com']
|
16
|
+
|
17
|
+
spec.summary = %q{"Git plugin for Flo"}
|
18
|
+
spec.homepage = "https://github.com/salesforce/git_flo"
|
19
|
+
spec.license = "BSD-3-Clause"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
|
29
|
+
spec.add_dependency 'rugged'
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
# Licensed under the BSD 3-Clause license.
|
4
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
5
|
+
|
6
|
+
require 'ostruct'
|
7
|
+
require 'rugged'
|
8
|
+
|
9
|
+
module GitFlo
|
10
|
+
MissingRefError = Class.new(StandardError)
|
11
|
+
end
|
12
|
+
|
13
|
+
module Flo
|
14
|
+
module Provider
|
15
|
+
class GitFlo
|
16
|
+
|
17
|
+
def initialize(opts={})
|
18
|
+
@repo_location = opts[:repo_location] || '.'
|
19
|
+
|
20
|
+
@credentials = opts[:credentials]
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_out_or_create_branch(opts={})
|
24
|
+
name = opts[:name]
|
25
|
+
ref = opts[:source] || 'master'
|
26
|
+
remote = opts[:remote] || 'origin'
|
27
|
+
|
28
|
+
validate_branch_exists(ref)
|
29
|
+
|
30
|
+
if repo.remotes[remote]
|
31
|
+
repo.fetch(remote, credentials: credentials)
|
32
|
+
end
|
33
|
+
|
34
|
+
if repo.branches.exist? name
|
35
|
+
# noop
|
36
|
+
elsif repo.branches.exist? "origin/#{name}"
|
37
|
+
repo.create_branch(name, "origin/#{name}")
|
38
|
+
else
|
39
|
+
repo.create_branch(name, ref)
|
40
|
+
end
|
41
|
+
|
42
|
+
repo.checkout(name)
|
43
|
+
OpenStruct.new(success?: true)
|
44
|
+
end
|
45
|
+
|
46
|
+
def push(opts={})
|
47
|
+
remote = opts[:remote] || 'origin'
|
48
|
+
branch_name = repo.branches[opts[:branch]].canonical_name
|
49
|
+
repo.push(remote, branch_name)
|
50
|
+
|
51
|
+
OpenStruct.new(success?: true)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
attr_reader :credentials, :remote
|
57
|
+
|
58
|
+
def repo
|
59
|
+
@repo ||= Rugged::Repository.discover(@repo_location)
|
60
|
+
end
|
61
|
+
|
62
|
+
def validate_branch_exists(branch)
|
63
|
+
unless repo.branches.exist?(branch)
|
64
|
+
raise ::GitFlo::MissingRefError.new("Cannot create branch, as source branch #{branch} does not exist")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
# Licensed under the BSD 3-Clause license.
|
4
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
5
|
+
|
6
|
+
module GitFlo
|
7
|
+
VERSION = "0.0.1"
|
8
|
+
end
|
data/lib/git_flo.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Copyright © 2017, Salesforce.com, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
# Licensed under the BSD 3-Clause license.
|
4
|
+
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
5
|
+
|
6
|
+
require "git_flo/version"
|
7
|
+
|
8
|
+
module GitFlo
|
9
|
+
# Your code goes here...
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git_flo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Powers
|
8
|
+
- John Tuley
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.10'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.10'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rugged
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- justin.powers@salesforce.com
|
87
|
+
- jtuley@salesforce.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- git_flo.gemspec
|
98
|
+
- lib/flo/provider/git_flo.rb
|
99
|
+
- lib/git_flo.rb
|
100
|
+
- lib/git_flo/version.rb
|
101
|
+
homepage: https://github.com/salesforce/git_flo
|
102
|
+
licenses:
|
103
|
+
- BSD-3-Clause
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.5.2
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: '"Git plugin for Flo"'
|
125
|
+
test_files: []
|