socialcast-git-extensions 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/git-integrate +3 -4
- data/bin/git-promote +3 -4
- data/bin/git-prune-merged +2 -1
- data/bin/git-release +3 -4
- data/bin/git-reset-prototype +3 -3
- data/bin/git-reset-staging +3 -3
- data/bin/git-reviewrequest +4 -4
- data/bin/git-share +2 -1
- data/bin/git-start +3 -4
- data/bin/git-track +2 -1
- data/bin/git-update +2 -1
- data/lib/socialcast-git-extensions.rb +13 -57
- data/lib/socialcast-git-extensions/git.rb +52 -0
- data/lib/socialcast-git-extensions/github.rb +14 -0
- data/lib/socialcast-git-extensions/version.rb +2 -4
- data/socialcast-git-extensions.gemspec +1 -1
- metadata +5 -3
data/bin/git-integrate
CHANGED
@@ -5,13 +5,12 @@
|
|
5
5
|
# git integrate <ticket_id> <ticket_id2>...
|
6
6
|
|
7
7
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
8
|
-
include Socialcast
|
9
|
-
|
10
|
-
is_quiet = ARGV.delete("--quiet") || ARGV.delete("-q")
|
8
|
+
include Socialcast::Gitx
|
9
|
+
include Socialcast::Git
|
11
10
|
|
12
11
|
branch = current_branch
|
13
12
|
|
14
13
|
run_cmd 'git update'
|
15
14
|
integrate(branch, 'prototype')
|
16
15
|
|
17
|
-
|
16
|
+
share "#worklog integrating #{branch} into prototype #scgitx"
|
data/bin/git-promote
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
4
|
-
include Socialcast
|
5
|
-
|
6
|
-
is_quiet = ARGV.delete("--quiet") || ARGV.delete("-q")
|
4
|
+
include Socialcast::Gitx
|
5
|
+
include Socialcast::Git
|
7
6
|
|
8
7
|
branch = current_branch
|
9
8
|
|
@@ -14,4 +13,4 @@ integrate(branch, 'staging')
|
|
14
13
|
integrate('staging', 'prototype')
|
15
14
|
run_cmd "git checkout #{branch}"
|
16
15
|
|
17
|
-
|
16
|
+
share "#worklog promoting #{branch} into staging #scgitx"
|
data/bin/git-prune-merged
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
#usage -r --remote to prune remote branches
|
5
5
|
|
6
6
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
7
|
-
include Socialcast
|
7
|
+
include Socialcast::Gitx
|
8
|
+
include Socialcast::Git
|
8
9
|
|
9
10
|
remote = ARGV.delete("--remote") || ARGV.delete("-r")
|
10
11
|
|
data/bin/git-release
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
4
|
-
include Socialcast
|
4
|
+
include Socialcast::Gitx
|
5
|
+
include Socialcast::Git
|
5
6
|
|
6
7
|
branch = current_branch
|
7
8
|
abort("Cannot release reserved branch") if %w{master staging prototype}.include?(branch)
|
8
9
|
|
9
|
-
is_quiet = ARGV.delete("--quiet") || ARGV.delete("-q")
|
10
|
-
|
11
10
|
exit unless HighLine.agree("<%= color('Release #{branch} to production? (y/n)', :green) %>")
|
12
11
|
|
13
12
|
run_cmd 'git update'
|
@@ -18,4 +17,4 @@ integrate 'staging', 'prototype'
|
|
18
17
|
run_cmd "git checkout master"
|
19
18
|
run_cmd "grb rm #{branch}"
|
20
19
|
|
21
|
-
|
20
|
+
share "#worklog releasing #{branch} to production #scgitx"
|
data/bin/git-reset-prototype
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
4
|
-
include Socialcast
|
4
|
+
include Socialcast::Gitx
|
5
|
+
include Socialcast::Git
|
5
6
|
|
6
7
|
head_branch = ARGV.first || 'master'
|
7
8
|
reset_branch('prototype', head_branch)
|
@@ -9,5 +10,4 @@ reset_branch('last_known_good_prototype', head_branch)
|
|
9
10
|
|
10
11
|
HighLine.say "\n<%= color('Updating the following tickets to no longer be in prototype:', :red) %>"
|
11
12
|
|
12
|
-
|
13
|
-
run_cmd "socialcast share '#worklog resetting prototype branch #scgitx'" unless is_quiet
|
13
|
+
share "#worklog resetting prototype branch #scgitx"
|
data/bin/git-reset-staging
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
4
|
-
include Socialcast
|
4
|
+
include Socialcast::Gitx
|
5
|
+
include Socialcast::Git
|
5
6
|
|
6
7
|
head_branch = ARGV.first || 'last_known_good_staging'
|
7
8
|
reset_branch('staging', head_branch)
|
8
9
|
reset_branch('last_known_good_staging', head_branch)
|
9
10
|
|
10
|
-
|
11
|
-
run_cmd "socialcast share '#worklog resetting staging branch #scgitx'" unless is_quiet
|
11
|
+
share "#worklog resetting staging branch #scgitx"
|
data/bin/git-reviewrequest
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
# git reviewrequest
|
6
6
|
|
7
7
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
8
|
-
include Socialcast
|
9
|
-
|
10
|
-
|
8
|
+
include Socialcast::Gitx
|
9
|
+
include Socialcast::Git
|
10
|
+
include Socialcast::Github
|
11
11
|
|
12
12
|
branch = current_branch
|
13
13
|
username = `git config -z --global --get github.user`.strip
|
@@ -16,4 +16,4 @@ password = HighLine.ask("Github password: ") { |q| q.echo = false }
|
|
16
16
|
run_cmd 'git update'
|
17
17
|
|
18
18
|
url = create_pull_request username, password, branch
|
19
|
-
|
19
|
+
share "@SocialcastDevelopers #reviewrequest for #{branch} #scgitx", url
|
data/bin/git-share
CHANGED
data/bin/git-start
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
#start a new git branch with latest changes from master
|
4
4
|
|
5
5
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
|
6
|
-
include Socialcast
|
7
|
-
|
8
|
-
is_quiet = ARGV.delete("--quiet") || ARGV.delete("-q")
|
6
|
+
include Socialcast::Gitx
|
7
|
+
include Socialcast::Git
|
9
8
|
|
10
9
|
unless branch_name = ARGV.first
|
11
10
|
example_branch = %w{ api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link }.sort_by { rand }.first
|
@@ -23,4 +22,4 @@ run_cmd 'git checkout master'
|
|
23
22
|
run_cmd 'git pull'
|
24
23
|
run_cmd "git checkout -b #{branch_name}"
|
25
24
|
|
26
|
-
|
25
|
+
share "#worklog starting work on #{branch_name} #scgitx"
|
data/bin/git-track
CHANGED
data/bin/git-update
CHANGED
@@ -1,64 +1,20 @@
|
|
1
|
-
require 'grit'
|
2
1
|
require 'highline/import'
|
3
|
-
require '
|
4
|
-
require '
|
2
|
+
require 'socialcast-git-extensions/git'
|
3
|
+
require 'socialcast-git-extensions/github'
|
5
4
|
|
6
5
|
module Socialcast
|
7
6
|
module Gitx
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def branches(options = {})
|
22
|
-
branches = []
|
23
|
-
reserved_branches = %w{ HEAD master last_known_good_master staging last_known_good_staging next_release last_known_good_next_release }
|
24
|
-
args = []
|
25
|
-
args << '-r' if options[:remote]
|
26
|
-
args << '--merged' if options[:merged]
|
27
|
-
output = `git branch #{args.join(' ')}`.split("\n")
|
28
|
-
output.each do |branch|
|
29
|
-
branch = branch.gsub(/\*/, '').strip.split(' ').first
|
30
|
-
branch = branch.split('/').last if options[:remote]
|
31
|
-
branches << branch unless reserved_branches.include?(branch)
|
7
|
+
class << self
|
8
|
+
def run_cmd(cmd)
|
9
|
+
HighLine.say "\n> <%= color('#{cmd.gsub("'", '')}', :red) %>"
|
10
|
+
raise "#{cmd} failed" unless system cmd
|
11
|
+
end
|
12
|
+
def share(message, url = nil)
|
13
|
+
return if ARGV.delete("--quiet") || ARGV.delete("-q")
|
14
|
+
cmd = "socialcast share '#{message}'"
|
15
|
+
cmd += " --url #{url}" if url
|
16
|
+
run_cmd cmd
|
17
|
+
end
|
32
18
|
end
|
33
|
-
branches
|
34
|
-
end
|
35
|
-
def reset_branch(branch, head_branch = 'master')
|
36
|
-
return if branch == head_branch
|
37
|
-
run_cmd "git checkout #{head_branch}"
|
38
|
-
run_cmd "git pull"
|
39
|
-
run_cmd "git branch -D #{branch}" rescue nil
|
40
|
-
run_cmd "git push origin :#{branch}" rescue nil
|
41
|
-
run_cmd "git checkout -b #{branch}"
|
42
|
-
run_cmd "grb publish #{branch}"
|
43
|
-
run_cmd "git checkout #{head_branch}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def integrate(branch, destination_branch = 'staging')
|
47
|
-
HighLine.say "integrating <%= color('#{branch}', :green) %> into <%= color('#{destination_branch}', :green) %>"
|
48
|
-
run_cmd "git remote prune origin"
|
49
|
-
unless destination_branch == 'master'
|
50
|
-
run_cmd "git branch -D #{destination_branch}" rescue nil
|
51
|
-
run_cmd "grb track #{destination_branch}"
|
52
|
-
end
|
53
|
-
run_cmd "git checkout #{destination_branch}"
|
54
|
-
run_cmd "git pull . #{branch}"
|
55
|
-
run_cmd "git push origin HEAD"
|
56
|
-
|
57
|
-
run_cmd "git checkout #{branch}"
|
58
|
-
end
|
59
|
-
def create_pull_request(username, password, branch)
|
60
|
-
response = RestClient.post "https://#{username}:#{password}@api.github.com/repos/socialcast/socialcast/pulls", {:title => branch, :base => 'master', :head => branch}.to_json, :accept => :json, :content_type => :json
|
61
|
-
data = JSON.parse response.body
|
62
|
-
url = data['html_url']
|
63
19
|
end
|
64
20
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'grit'
|
2
|
+
|
3
|
+
module Socialcast
|
4
|
+
module Git
|
5
|
+
include Socialcast::Gitx
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def current_branch
|
9
|
+
repo = Grit::Repo.new(Dir.pwd)
|
10
|
+
Grit::Head.current(repo).name
|
11
|
+
end
|
12
|
+
def branches(options = {})
|
13
|
+
branches = []
|
14
|
+
reserved_branches = %w{ HEAD master last_known_good_master staging last_known_good_staging next_release last_known_good_next_release }
|
15
|
+
args = []
|
16
|
+
args << '-r' if options[:remote]
|
17
|
+
args << '--merged' if options[:merged]
|
18
|
+
output = `git branch #{args.join(' ')}`.split("\n")
|
19
|
+
output.each do |branch|
|
20
|
+
branch = branch.gsub(/\*/, '').strip.split(' ').first
|
21
|
+
branch = branch.split('/').last if options[:remote]
|
22
|
+
branches << branch unless reserved_branches.include?(branch)
|
23
|
+
end
|
24
|
+
branches
|
25
|
+
end
|
26
|
+
def reset_branch(branch, head_branch = 'master')
|
27
|
+
return if branch == head_branch
|
28
|
+
run_cmd "git checkout #{head_branch}"
|
29
|
+
run_cmd "git pull"
|
30
|
+
run_cmd "git branch -D #{branch}" rescue nil
|
31
|
+
run_cmd "git push origin :#{branch}" rescue nil
|
32
|
+
run_cmd "git checkout -b #{branch}"
|
33
|
+
run_cmd "grb publish #{branch}"
|
34
|
+
run_cmd "git checkout #{head_branch}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def integrate(branch, destination_branch = 'staging')
|
38
|
+
HighLine.say "integrating <%= color('#{branch}', :green) %> into <%= color('#{destination_branch}', :green) %>"
|
39
|
+
run_cmd "git remote prune origin"
|
40
|
+
unless destination_branch == 'master'
|
41
|
+
run_cmd "git branch -D #{destination_branch}" rescue nil
|
42
|
+
run_cmd "grb track #{destination_branch}"
|
43
|
+
end
|
44
|
+
run_cmd "git checkout #{destination_branch}"
|
45
|
+
run_cmd "git pull . #{branch}"
|
46
|
+
run_cmd "git push origin HEAD"
|
47
|
+
|
48
|
+
run_cmd "git checkout #{branch}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Socialcast
|
5
|
+
module Github
|
6
|
+
class << self
|
7
|
+
def create_pull_request(username, password, branch)
|
8
|
+
response = RestClient.post "https://#{username}:#{password}@api.github.com/repos/socialcast/socialcast/pulls", {:title => branch, :base => 'master', :head => branch}.to_json, :accept => :json, :content_type => :json
|
9
|
+
data = JSON.parse response.body
|
10
|
+
url = data['html_url']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,7 +4,7 @@ require "socialcast-git-extensions/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "socialcast-git-extensions"
|
7
|
-
s.version = Socialcast::
|
7
|
+
s.version = Socialcast::Gitx::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Ryan Sonnek"]
|
10
10
|
s.email = ["ryan@socialcast.com"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialcast-git-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
9
|
+
- 2
|
10
|
+
version: 2.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -161,6 +161,8 @@ files:
|
|
161
161
|
- bin/git-update
|
162
162
|
- bin/git-wtf
|
163
163
|
- lib/socialcast-git-extensions.rb
|
164
|
+
- lib/socialcast-git-extensions/git.rb
|
165
|
+
- lib/socialcast-git-extensions/github.rb
|
164
166
|
- lib/socialcast-git-extensions/version.rb
|
165
167
|
- socialcast-git-extensions.gemspec
|
166
168
|
- test/helper.rb
|