geordi 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -16
- data/bin/gitpt +4 -0
- data/lib/geordi/gitpt.rb +175 -0
- data/lib/geordi/version.rb +1 -1
- metadata +9 -8
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Enables the given virtual host in `/etc/apache2/sites-available` and disables al
|
|
17
17
|
|
18
18
|
site makandra-com
|
19
19
|
|
20
|
-
More information at http://
|
20
|
+
More information at http://makandracards.com/makandra/807-shell-script-to-quickly-switch-apache-sites
|
21
21
|
|
22
22
|
|
23
23
|
b
|
@@ -27,7 +27,7 @@ Runs the given command under `bundle exec` if a `Gemfile` is present in your wor
|
|
27
27
|
|
28
28
|
b spec spec/models
|
29
29
|
|
30
|
-
More information at http://
|
30
|
+
More information at http://makandracards.com/makandra/684-automatically-run-bundle-exec-if-required
|
31
31
|
|
32
32
|
|
33
33
|
console-for
|
@@ -37,7 +37,7 @@ Opens a rails console remotely:
|
|
37
37
|
|
38
38
|
console-for staging
|
39
39
|
|
40
|
-
More information at http://
|
40
|
+
More information at http://makandracards.com/makandra/1338-console-for-opens-a-rails-console-remotely-on-a-capistrano-deployment-target
|
41
41
|
|
42
42
|
|
43
43
|
|
@@ -48,7 +48,7 @@ Runs Cucumber with the arguments you want: bundle exec, cucumber_spinner detecti
|
|
48
48
|
|
49
49
|
cuc features/users.feature
|
50
50
|
|
51
|
-
More information at http://
|
51
|
+
More information at http://makandracards.com/makandra/1277-a-nicer-way-to-run-rspec-and-or-cucumber
|
52
52
|
|
53
53
|
|
54
54
|
|
@@ -59,7 +59,7 @@ Removes unnecessary files from your project directory:
|
|
59
59
|
|
60
60
|
cleanup-directory
|
61
61
|
|
62
|
-
More information at http://
|
62
|
+
More information at http://makandracards.com/makandra/951-shell-script-to-clean-up-a-project-directory
|
63
63
|
|
64
64
|
|
65
65
|
dump-for
|
@@ -69,7 +69,7 @@ Dumps the database on your server for a given [Capistrano multistage](https://gi
|
|
69
69
|
|
70
70
|
dump-for production
|
71
71
|
|
72
|
-
More information at http://
|
72
|
+
More information at http://makandracards.com/makandra/1237-script-to-create-and-copy-a-production-dump-to-your-project-root
|
73
73
|
|
74
74
|
|
75
75
|
|
@@ -80,7 +80,21 @@ Stores a timestamped database dump for the given Rails environment in `~/dumps`:
|
|
80
80
|
|
81
81
|
dumple development
|
82
82
|
|
83
|
-
More information at http://
|
83
|
+
More information at http://makandracards.com/makandra/1008-dump-your-database-with-dumple
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
gitpt
|
88
|
+
-----
|
89
|
+
|
90
|
+
Shell script to generate a git commit with Pivotal Tracker story ID and title. Run it from your project directory:
|
91
|
+
|
92
|
+
gitpt
|
93
|
+
|
94
|
+
This lets you choose from all started, finished and rejected stories in Pivotal Tracker and commit staged changes.
|
95
|
+
Requires the project's Pivotal Tracker ID(s) to be defined in a `.pt_project_id` file in the project's directory.
|
96
|
+
|
97
|
+
More information at https://makandracards.com/makandra/1372-shell-script-to-generate-a-git-commit-with-pivotal-tracker-story-id-and-title
|
84
98
|
|
85
99
|
|
86
100
|
install-gems-remotely
|
@@ -90,7 +104,7 @@ Installs all gems in your `Gemfile.lock`, as well as vendored gems, to the given
|
|
90
104
|
|
91
105
|
install-gems-remotely my.server.com
|
92
106
|
|
93
|
-
More information at http://
|
107
|
+
More information at http://makandracards.com/makandra/692-install-a-local-gemfile-on-a-remote-server
|
94
108
|
|
95
109
|
|
96
110
|
migrate-all
|
@@ -109,7 +123,7 @@ Calls the Capistrano tasks `deploy`, `deploy:migrate` and `deploy:restart` on th
|
|
109
123
|
|
110
124
|
power-deploy staging
|
111
125
|
|
112
|
-
This script is considered legacy and will be removed eventually. You should [fix your deploy scripts](http://
|
126
|
+
This script is considered legacy and will be removed eventually. You should [fix your deploy scripts](http://makandracards.com/makandra/1176-which-capistrano-hooks-to-use-for-events-to-happen-on-both-cap-deploy-and-cap-deploy-migrations) and then use [cap deploy:migrations](http://makandracards.com/makandra/1000-deploy-and-migrate-with-a-single-capistrano-command).
|
113
127
|
|
114
128
|
|
115
129
|
power-rake
|
@@ -119,7 +133,7 @@ Runs the given rake task in each Rails environment in `development`, `test`, `cu
|
|
119
133
|
|
120
134
|
power-rake db:migrate
|
121
135
|
|
122
|
-
More information at http://
|
136
|
+
More information at http://makandracards.com/makandra/737-run-a-rake-task-in-all-environments
|
123
137
|
|
124
138
|
|
125
139
|
remotify-local-branch
|
@@ -129,7 +143,7 @@ Pushes the given branch to the remote `origin` and tracks it:
|
|
129
143
|
|
130
144
|
remotify-local-branch redesign
|
131
145
|
|
132
|
-
More information at http://
|
146
|
+
More information at http://makandracards.com/makandra/520-create-a-remote-branch-in-git
|
133
147
|
|
134
148
|
|
135
149
|
remove-executable-flags
|
@@ -139,7 +153,7 @@ Recursively removes executable flags from files in the working directory that pr
|
|
139
153
|
|
140
154
|
remove-executable-flags
|
141
155
|
|
142
|
-
More information at http://
|
156
|
+
More information at http://makandracards.com/makandra/659-recursively-remove-unnecessary-execute-flags
|
143
157
|
|
144
158
|
|
145
159
|
rs
|
@@ -149,7 +163,7 @@ Runs RSpec with the arguments you want: RSpec 1/2 detection, bundle exec, rspec_
|
|
149
163
|
|
150
164
|
rs spec/models/user_spec.rb
|
151
165
|
|
152
|
-
More information at http://
|
166
|
+
More information at http://makandracards.com/makandra/1277-a-nicer-way-to-run-rspec-and-or-cucumber
|
153
167
|
|
154
168
|
|
155
169
|
setup-firefox-for-selenium
|
@@ -159,7 +173,7 @@ Helps you create an frozen version of Firefox, so your Selenium tests will no lo
|
|
159
173
|
|
160
174
|
setup-firefox-for-selenium
|
161
175
|
|
162
|
-
More information at http://
|
176
|
+
More information at http://makandracards.com/makandra/1575-how-to-install-a-frozen-version-of-firefox-for-your-selenium-tests
|
163
177
|
|
164
178
|
|
165
179
|
shell-for
|
@@ -173,7 +187,7 @@ Now it can also be called with any command to be remotely executed before loadin
|
|
173
187
|
|
174
188
|
shell-for staging --no-bash top
|
175
189
|
|
176
|
-
More information at http://
|
190
|
+
More information at http://makandracards.com/makandra/1209-script-to-open-an-ssh-shell-to-a-capistrano-deployment-target
|
177
191
|
|
178
192
|
|
179
193
|
tests
|
@@ -183,4 +197,4 @@ Runs both `rs` and `cuc`. Call from any project directory:
|
|
183
197
|
|
184
198
|
tests
|
185
199
|
|
186
|
-
More information at http://
|
200
|
+
More information at http://makandracards.com/makandra/1277-a-nicer-way-to-run-rspec-and-or-cucumber
|
data/bin/gitpt
ADDED
data/lib/geordi/gitpt.rb
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'highline'
|
3
|
+
require 'pivotal-tracker'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Geordi
|
7
|
+
class Gitpt
|
8
|
+
|
9
|
+
attr_reader :token, :initials, :settings_file, :deprecated_token_file,
|
10
|
+
:highline, :applicable_stories, :memberships
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@highline = HighLine.new
|
14
|
+
@settings_file = File.join(ENV['HOME'], '.gitpt')
|
15
|
+
@deprecated_token_file = File.join(ENV['HOME'], '.pt_token')
|
16
|
+
load_settings
|
17
|
+
settings_were_invalid = (not settings_valid?)
|
18
|
+
|
19
|
+
hello unless settings_valid?
|
20
|
+
request_settings while not settings_valid?
|
21
|
+
stored if settings_were_invalid
|
22
|
+
|
23
|
+
PivotalTracker::Client.use_ssl = true
|
24
|
+
PivotalTracker::Client.token = token
|
25
|
+
end
|
26
|
+
|
27
|
+
def settings_valid?
|
28
|
+
token and token.size > 10
|
29
|
+
end
|
30
|
+
|
31
|
+
def bold(string)
|
32
|
+
HighLine::BOLD + string + HighLine::RESET
|
33
|
+
end
|
34
|
+
|
35
|
+
def highlight(string)
|
36
|
+
bold HighLine::BLUE + string
|
37
|
+
end
|
38
|
+
|
39
|
+
def hello
|
40
|
+
highline.say HighLine::RESET
|
41
|
+
highline.say "Welcome to #{bold 'gitpt'}.\n\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def left(string)
|
45
|
+
leading_whitespace = (string.match(/\A( +)[^ ]+/) || [])[1]
|
46
|
+
string.gsub! /^#{leading_whitespace}/, '' if leading_whitespace
|
47
|
+
string
|
48
|
+
end
|
49
|
+
|
50
|
+
def loading(message, &block)
|
51
|
+
print message
|
52
|
+
STDOUT.flush
|
53
|
+
yield
|
54
|
+
print "\r" + ' ' * message.size + "\r" # Remove loading message
|
55
|
+
STDOUT.flush
|
56
|
+
end
|
57
|
+
|
58
|
+
def stored
|
59
|
+
highline.say left(<<-MESSAGE)
|
60
|
+
Thank you. Your settings have been stored at #{highlight @settings_file}
|
61
|
+
You may remove that file for the wizard to reappear.
|
62
|
+
|
63
|
+
----------------------------------------------------
|
64
|
+
|
65
|
+
MESSAGE
|
66
|
+
end
|
67
|
+
|
68
|
+
def request_settings
|
69
|
+
highline.say highlight('Your settings are missing or invalid.')
|
70
|
+
highline.say "Please configure your Pivotal Tracker access.\n\n"
|
71
|
+
token = highline.ask bold("Your API key:") + " "
|
72
|
+
initials = highline.ask bold("Your PT initials") + " (optional, used for highlighting your stories): "
|
73
|
+
highline.say "\n"
|
74
|
+
|
75
|
+
settings = { :token => token, :initials => initials }
|
76
|
+
File.open settings_file, 'w' do |file|
|
77
|
+
file.write settings.to_yaml
|
78
|
+
end
|
79
|
+
load_settings
|
80
|
+
end
|
81
|
+
|
82
|
+
def load_settings
|
83
|
+
if File.exists? settings_file
|
84
|
+
settings = YAML.load(File.read settings_file)
|
85
|
+
@initials = settings[:initials]
|
86
|
+
@token = settings[:token]
|
87
|
+
else
|
88
|
+
if File.exists?(deprecated_token_file)
|
89
|
+
highline.say left(<<-MESSAGE)
|
90
|
+
#{HighLine::YELLOW}You are still using #{highlight(deprecated_token_file) + HighLine::YELLOW} which will be deprecated in a future version.
|
91
|
+
Please migrate your settings to ~/.gitpt or remove #{deprecated_token_file} for the wizard to cast magic.
|
92
|
+
MESSAGE
|
93
|
+
@token = File.read(deprecated_token_file)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def load_projects
|
99
|
+
project_id_filename = '.pt_project_id'
|
100
|
+
if File.exists?(project_id_filename)
|
101
|
+
project_ids = File.read('.pt_project_id').split(/[\s]+/).map(&:to_i)
|
102
|
+
end
|
103
|
+
|
104
|
+
unless project_ids and project_ids.size > 0
|
105
|
+
highline.say left(<<-MESSAGE)
|
106
|
+
Sorry, I could not find a project ID in #{highlight project_id_filename} :(
|
107
|
+
|
108
|
+
Please put at least one Pivotal Tracker project id into #{project_id_filename} in this directory.
|
109
|
+
You may add multiple IDs, separated using white space.
|
110
|
+
MESSAGE
|
111
|
+
exit 1
|
112
|
+
end
|
113
|
+
|
114
|
+
loading 'Connecting to Pivotal Tracker...' do
|
115
|
+
projects = project_ids.collect do |project_id|
|
116
|
+
PivotalTracker::Project.find(project_id)
|
117
|
+
end
|
118
|
+
|
119
|
+
@memberships = projects.collect(&:memberships).map(&:all).flatten
|
120
|
+
|
121
|
+
@applicable_stories = projects.collect do |project|
|
122
|
+
project.stories.all(:state => 'started,finished,rejected')
|
123
|
+
end.flatten
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def choose_story
|
128
|
+
selected_story = nil
|
129
|
+
|
130
|
+
highline.choose do |menu|
|
131
|
+
menu.header = "Choose a story"
|
132
|
+
applicable_stories.each do |story|
|
133
|
+
owner_name = story.owned_by
|
134
|
+
owner = if owner_name
|
135
|
+
owners = memberships.select{|member| member.name == owner_name}
|
136
|
+
owners.first ? owners.first.initials : '?'
|
137
|
+
else
|
138
|
+
'?'
|
139
|
+
end
|
140
|
+
|
141
|
+
state = story.current_state
|
142
|
+
if state == 'started'
|
143
|
+
state = HighLine::GREEN + state + HighLine::RESET
|
144
|
+
elsif state != 'finished'
|
145
|
+
state = HighLine::RED + state + HighLine::RESET
|
146
|
+
end
|
147
|
+
state += HighLine::BOLD if owner == initials
|
148
|
+
|
149
|
+
label = "(#{owner}, #{state}) #{story.name}"
|
150
|
+
label = bold(label) if owner == initials
|
151
|
+
menu.choice(label) { selected_story = story }
|
152
|
+
end
|
153
|
+
menu.hidden ''
|
154
|
+
end
|
155
|
+
|
156
|
+
if selected_story
|
157
|
+
message = highline.ask("\nAdd an optional message")
|
158
|
+
highline.say message
|
159
|
+
|
160
|
+
commit_message = "[##{selected_story.id}] #{selected_story.name}"
|
161
|
+
if message.strip != ''
|
162
|
+
commit_message << ' - '<< message.strip
|
163
|
+
end
|
164
|
+
|
165
|
+
exec('git', 'commit', '-m', commit_message)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def run
|
170
|
+
load_projects
|
171
|
+
choose_story
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
end
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-01-10 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.
|
@@ -30,6 +29,7 @@ executables:
|
|
30
29
|
- cuc
|
31
30
|
- dump-for
|
32
31
|
- dumple
|
32
|
+
- gitpt
|
33
33
|
- install-gems-remotely
|
34
34
|
- install-gems-remotely.sh
|
35
35
|
- migrate-all
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- bin/cuc
|
58
58
|
- bin/dump-for
|
59
59
|
- bin/dumple
|
60
|
+
- bin/gitpt
|
60
61
|
- bin/install-gems-remotely
|
61
62
|
- bin/install-gems-remotely.sh
|
62
63
|
- bin/migrate-all
|
@@ -70,9 +71,9 @@ files:
|
|
70
71
|
- bin/tests
|
71
72
|
- geordi.gemspec
|
72
73
|
- lib/geordi.rb
|
74
|
+
- lib/geordi/gitpt.rb
|
73
75
|
- lib/geordi/setup_firefox_for_selenium.rb
|
74
76
|
- lib/geordi/version.rb
|
75
|
-
has_rdoc: true
|
76
77
|
homepage: http://makandra.com
|
77
78
|
licenses: []
|
78
79
|
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
requirements: []
|
103
104
|
|
104
105
|
rubyforge_project: geordi
|
105
|
-
rubygems_version: 1.
|
106
|
+
rubygems_version: 1.8.5
|
106
107
|
signing_key:
|
107
108
|
specification_version: 3
|
108
109
|
summary: Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.
|