v2gpti 1.1.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/bin/git-deliver +1 -1
  3. data/bin/git-finish +1 -1
  4. data/bin/git-newbug +1 -1
  5. data/bin/git-newfeature +1 -1
  6. data/bin/git-qa +1 -1
  7. data/bin/git-release +1 -1
  8. data/bin/git-report +1 -1
  9. data/bin/git-start +1 -1
  10. data/bin/git-uat +1 -1
  11. data/config_template +16 -0
  12. data/lib/git-pivotal-tracker-integration/command/base.rb +235 -322
  13. data/lib/git-pivotal-tracker-integration/command/configuration.rb +183 -109
  14. data/lib/git-pivotal-tracker-integration/command/deliver.rb +145 -200
  15. data/lib/git-pivotal-tracker-integration/command/finish.rb +70 -63
  16. data/lib/git-pivotal-tracker-integration/command/newbug.rb +36 -39
  17. data/lib/git-pivotal-tracker-integration/command/newfeature.rb +43 -42
  18. data/lib/git-pivotal-tracker-integration/command/release.rb +171 -203
  19. data/lib/git-pivotal-tracker-integration/command/report.rb +33 -36
  20. data/lib/git-pivotal-tracker-integration/command/start.rb +74 -78
  21. data/lib/git-pivotal-tracker-integration/util/git.rb +202 -204
  22. data/lib/git-pivotal-tracker-integration/util/shell.rb +19 -16
  23. data/lib/git-pivotal-tracker-integration/util/story.rb +155 -177
  24. data/lib/git-pivotal-tracker-integration/version-update/gradle.rb +44 -40
  25. data/lib/git-pivotal-tracker-integration.rb +44 -0
  26. data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +1 -2
  27. data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +1 -1
  28. data/spec/git-pivotal-tracker-integration/command/release_spec.rb +1 -1
  29. data/spec/git-pivotal-tracker-integration/command/start_spec.rb +1 -1
  30. data/spec/git-pivotal-tracker-integration/util/story_spec.rb +21 -32
  31. data/tracker_api/lib/tracker_api/client.rb +241 -0
  32. data/tracker_api/lib/tracker_api/endpoints/activity.rb +38 -0
  33. data/tracker_api/lib/tracker_api/endpoints/comments.rb +27 -0
  34. data/tracker_api/lib/tracker_api/endpoints/epic.rb +17 -0
  35. data/tracker_api/lib/tracker_api/endpoints/epics.rb +20 -0
  36. data/tracker_api/lib/tracker_api/endpoints/file_attachment.rb +18 -0
  37. data/tracker_api/lib/tracker_api/endpoints/iterations.rb +20 -0
  38. data/tracker_api/lib/tracker_api/endpoints/me.rb +17 -0
  39. data/tracker_api/lib/tracker_api/endpoints/memberships.rb +20 -0
  40. data/tracker_api/lib/tracker_api/endpoints/notifications.rb +20 -0
  41. data/tracker_api/lib/tracker_api/endpoints/project.rb +17 -0
  42. data/tracker_api/lib/tracker_api/endpoints/projects.rb +18 -0
  43. data/tracker_api/lib/tracker_api/endpoints/stories.rb +20 -0
  44. data/tracker_api/lib/tracker_api/endpoints/story.rb +37 -0
  45. data/tracker_api/lib/tracker_api/endpoints/tasks.rb +20 -0
  46. data/tracker_api/lib/tracker_api/error.rb +18 -0
  47. data/tracker_api/lib/tracker_api/logger.rb +31 -0
  48. data/tracker_api/lib/tracker_api/resources/account.rb +18 -0
  49. data/tracker_api/lib/tracker_api/resources/activity.rb +24 -0
  50. data/tracker_api/lib/tracker_api/resources/base.rb +71 -0
  51. data/tracker_api/lib/tracker_api/resources/change.rb +15 -0
  52. data/tracker_api/lib/tracker_api/resources/comment.rb +20 -0
  53. data/tracker_api/lib/tracker_api/resources/epic.rb +17 -0
  54. data/tracker_api/lib/tracker_api/resources/file_attachment.rb +23 -0
  55. data/tracker_api/lib/tracker_api/resources/iteration.rb +24 -0
  56. data/tracker_api/lib/tracker_api/resources/label.rb +14 -0
  57. data/tracker_api/lib/tracker_api/resources/me.rb +21 -0
  58. data/tracker_api/lib/tracker_api/resources/membership_summary.rb +15 -0
  59. data/tracker_api/lib/tracker_api/resources/notification.rb +26 -0
  60. data/tracker_api/lib/tracker_api/resources/person.rb +14 -0
  61. data/tracker_api/lib/tracker_api/resources/primary_resource.rb +13 -0
  62. data/tracker_api/lib/tracker_api/resources/project.rb +131 -0
  63. data/tracker_api/lib/tracker_api/resources/project_membership.rb +16 -0
  64. data/tracker_api/lib/tracker_api/resources/story.rb +102 -0
  65. data/tracker_api/lib/tracker_api/resources/task.rb +16 -0
  66. data/tracker_api/lib/tracker_api/resources/time_zone.rb +13 -0
  67. data/tracker_api/lib/tracker_api/version.rb +3 -0
  68. data/tracker_api/lib/tracker_api.rb +60 -0
  69. metadata +202 -53
  70. data/lib/git-pivotal-tracker-integration/command/command.rb +0 -20
  71. data/lib/git-pivotal-tracker-integration/util/util.rb +0 -20
  72. data/lib/git-pivotal-tracker-integration/version-update/version_update.rb +0 -20
  73. data/lib/git_pivotal_tracker_integration.rb +0 -18
@@ -13,50 +13,51 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require 'git-pivotal-tracker-integration/command/base'
17
- require 'git-pivotal-tracker-integration/command/command'
18
- require 'git-pivotal-tracker-integration/util/git'
19
- require 'git-pivotal-tracker-integration/util/story'
20
- require 'pivotal-tracker'
16
+ module GitPivotalTrackerIntegration
17
+ module Command
21
18
 
22
- # The class that encapsulates creating a Pivotal Tracker Feature Story
23
- class GitPivotalTrackerIntegration::Command::Newfeature < GitPivotalTrackerIntegration::Command::Base
19
+ # The class that encapsulates creating a Pivotal Tracker Feature Story
20
+ class Newfeature < Base
21
+
22
+ # Creates a Pivotal Tracker story by doing the following steps:
23
+ # * Takes arguments from command line
24
+ # * If arguments contains -i then it creates a feature story under icebox
25
+ # * If arguments contains -b then it creates a feature story under backlog
26
+ # * If arguments contains -tl then it creates a feature story at top of specified list
27
+ # * If arguments contains -bl then it creates a feature story at bottom of specified list
28
+ # * If arguments contains -p1 then it creates a feature story with estimate as 1 point.
29
+ # * If arguments contains -p2 then it creates a feature story with estimate as 2 points.
30
+ # * If arguments contains -p3 then it creates a feature story with estimate as 3 points.
31
+ # * If there are no arguments passed then it creates a feature story in icebox top of the list if you wish to create
32
+ def run(args)
33
+
34
+ $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}")
35
+ story = nil
36
+ if (!args.empty? && args.any?{|arg| arg.include?("-i")})
37
+ story = self.create_icebox_feature_story(args)
38
+ elsif (!args.empty? && args.any?{|arg| arg.include?("-b")})
39
+ story = self.create_backlog_feature_story(args)
40
+ else
41
+ puts "\n Syntax for creating new feature story in icebox top of the list:\n git newfeature -i -tl <feature-title> \n Syntax for creating new feature story in icebox bottom of the list: \n git newfeature -i -bl <feature-title>\n"
42
+ puts "\n Syntax for creating new feature story in backlog top of the list:\n git newfeature -b -tl <feature-title> \n Syntax for creating new feature story in backlog bottom of the list: \n git newfeature -b -bl <feature-title>\n"
43
+ user_response = nil
44
+ while (user_response.nil? || user_response.empty?)
45
+ user_response = ask("\nYou have missed some parameters to pass...If you are ok with creating new feature story in icebox then enter y otherwise enter n")
46
+ end
47
+ while !(["y","n"].include?(user_response.downcase))
48
+ user_response = ask("\nInvalid entry...If you are ok with creating new feature story in icebox then enter y otherwise enter n")
49
+ end
50
+ if user_response.downcase == "y"
51
+ story = self.create_icebox_feature_story(args)
52
+ else
53
+ abort "\nCheck your new feature story creation syntax and then try again"
54
+ end
55
+ end
56
+ puts "A new feature story has been created successfully with ID:#{story.id}"
57
+ end
24
58
 
25
- # Creates a Pivotal Tracker story by doing the following steps:
26
- # * Takes arguments from command line
27
- # * If arguments contains -i then it creates a feature story under icebox
28
- # * If arguments contains -b then it creates a feature story under backlog
29
- # * If arguments contains -tl then it creates a feature story at top of specified list
30
- # * If arguments contains -bl then it creates a feature story at bottom of specified list
31
- # * If arguments contains -p1 then it creates a feature story with estimate as 1 point.
32
- # * If arguments contains -p2 then it creates a feature story with estimate as 2 points.
33
- # * If arguments contains -p3 then it creates a feature story with estimate as 3 points.
34
- # * If there are no arguments passed then it creates a feature story in icebox top of the list if you wish to create
35
- def run(args)
36
- my_projects = PivotalTracker::Project.all
37
- $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{GitPivotalTrackerIntegration::Util::Git.branch_name}")
38
- story = nil
39
- if (!args.empty? && args.any?{|arg| arg.include?("-i")})
40
- story = self.create_icebox_feature_story(args)
41
- elsif (!args.empty? && args.any?{|arg| arg.include?("-b")})
42
- story = self.create_backlog_feature_story(args)
43
- else
44
- puts "\n Syntax for creating new feature story in icebox top of the list:\n git newfeature -i -tl <feature-title> \n Syntax for creating new feature story in icebox bottom of the list: \n git newfeature -i -bl <feature-title>\n"
45
- puts "\n Syntax for creating new feature story in backlog top of the list:\n git newfeature -b -tl <feature-title> \n Syntax for creating new feature story in backlog bottom of the list: \n git newfeature -b -bl <feature-title>\n"
46
- user_response = nil
47
- while (user_response.nil? || user_response.empty?)
48
- user_response = ask("\nYou have missed some parameters to pass...If you are ok with creating new feature story in icebox then enter y otherwise enter n")
49
- end
50
- while !(["y","n"].include?(user_response.downcase))
51
- user_response = ask("\nInvalid entry...If you are ok with creating new feature story in icebox then enter y otherwise enter n")
52
- end
53
- if user_response.downcase == "y"
54
- story = self.create_icebox_feature_story(args)
55
- else
56
- abort "\nCheck your new feature story creation syntax and then try again"
57
- end
58
59
  end
59
- puts "A new feature story has been created successfully with ID:#{story.id}"
60
- end
61
60
 
61
+ end
62
62
  end
63
+
@@ -13,226 +13,194 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require 'git-pivotal-tracker-integration/command/base'
17
- require 'git-pivotal-tracker-integration/command/command'
18
- require 'git-pivotal-tracker-integration/util/git'
19
- require 'git-pivotal-tracker-integration/util/story'
20
- require 'git-pivotal-tracker-integration/version-update/gradle'
21
-
22
- # The class that encapsulates releasing a Pivotal Tracker Story
23
- class GitPivotalTrackerIntegration::Command::Release < GitPivotalTrackerIntegration::Command::Base
24
-
25
- # Releases a Pivotal Tracker story by doing the following steps:
26
- # * Update the version to the release version
27
- # * Create a tag for the release version
28
- # * Update the version to the new development version
29
- # * Push tag and changes to remote
30
- #
31
- # @param [String, nil] filter a filter for selecting the release to start. This
32
- # filter can be either:
33
- # * a story id
34
- # * +nil+
35
- # @return [void]
36
- def run(filter)
37
- $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{GitPivotalTrackerIntegration::Util::Git.branch_name}")
38
- story = GitPivotalTrackerIntegration::Util::Story.select_release(@project, filter.nil? ? 'v' : filter)
39
- place_version_release story
40
- pull_out_rejected_stories story
41
- GitPivotalTrackerIntegration::Util::Story.pretty_print story
42
- $LOG.debug("story:#{story.name}")
43
-
44
- current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name
45
-
46
- # checkout QA branch
47
- # Update QA from origin
48
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout QA"
49
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git fetch"
50
- GitPivotalTrackerIntegration::Util::Shell.exec "git merge -s recursive --strategy-option theirs origin QA"
51
-
52
- # checkout master branch
53
- # Merge QA into master
54
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout master"
55
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git pull"
56
- if (GitPivotalTrackerIntegration::Util::Shell.exec "git merge -s recursive --strategy-option theirs QA")
57
- puts "Merged 'QA' in to 'master'"
58
- else
59
- abort "FAILED to merge 'QA' in to 'master'"
60
- end
61
-
62
- # Update version and build numbers
63
- version_number = story.name.dup
64
- version_number[0] = ""
65
- working_directory = pwd
16
+ module GitPivotalTrackerIntegration
17
+ module Command
18
+
19
+ # The class that encapsulates releasing a Pivotal Tracker Story
20
+ class Release < Base
21
+
22
+ # Releases a Pivotal Tracker story by doing the following steps:
23
+ # * Update the version to the release version
24
+ # * Create a tag for the release version
25
+ # * Update the version to the new development version
26
+ # * Push tag and changes to remote
27
+ #
28
+ # @param [String, nil] filter a filter for selecting the release to start. This
29
+ # filter can be either:
30
+ # * a story id
31
+ # * +nil+
32
+ # @return [void]
33
+ def run(filter)
34
+
35
+ $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}")
36
+ story = Util::Story.select_release(@project, filter.nil? ? 'v' : filter)
37
+ place_version_release story
38
+ pull_out_rejected_stories story
39
+ Util::Story.pretty_print story
40
+ $LOG.debug("story:#{story.name}")
41
+
42
+ current_branch = Util::Git.branch_name
43
+
44
+ # checkout QA branch
45
+ # Update QA from origin
46
+ puts Util::Shell.exec "git checkout QA"
47
+ Util::Shell.exec "git reset --hard origin/QA"
48
+ puts Util::Shell.exec "git fetch"
49
+ Util::Shell.exec "git merge -s recursive --strategy-option theirs origin QA"
50
+
51
+
52
+ # checkout master branch
53
+ # Merge QA into master
54
+ puts Util::Shell.exec "git checkout master"
55
+ puts Util::Shell.exec "git pull"
56
+ if (Util::Shell.exec "git merge -s recursive --strategy-option theirs QA")
57
+ puts "Merged 'QA' in to 'master'"
58
+ else
59
+ abort "FAILED to merge 'QA' in to 'master'"
60
+ end
66
61
 
67
- puts "storyNAME:#{story.name}"
68
- puts "version_number:#{version_number}"
69
- puts "working_directory:#{working_directory}*"
62
+ # Update version and build numbers
63
+ version_number = story.name.dup
64
+ version_number[0] = ""
65
+ working_directory = pwd
66
+
67
+ puts "Story Name: #{story.name}"
68
+ puts "Version Number: #{version_number}"
69
+ puts "Working Directory: #{working_directory}*"
70
+ puts ""
71
+
72
+ if (OS.mac? && @platform.downcase == "ios")
73
+ project_directory = ((Util::Shell.exec 'find . -name "*.xcodeproj" 2>/dev/null').split /\/(?=[^\/]*$)/)[0]
74
+
75
+ # cd to the project_directory
76
+ Dir.chdir(project_directory)
77
+
78
+ # set project number in project file
79
+ pwd
80
+ puts Util::Shell.exec "xcrun agvtool new-marketing-version #{version_number}"
81
+
82
+ # cd back to the working_directory
83
+ Dir.chdir(working_directory)
84
+ # Change spec version
85
+ change_spec_version(version_number) if has_spec_path?
86
+ elsif @platform.downcase == 'android'
87
+ updater = VersionUpdate::Gradle.new(@repository_root)
88
+ updater.update_uat_version(version_number)
89
+ updater.update_prod_version(version_number)
90
+ elsif @platform.downcase == 'ruby-gem'
91
+ file = Dir["#{Util::Git.repository_root}/*.gemspec"].first
92
+ if file
93
+ file_text = File.read(file)
94
+ File.open(file, "w") {|gemspec| gemspec.puts file_text.gsub(/(?<!_)version(.*)=(.*)['|"]/, "version = '#{version_number}'")}
95
+ end
96
+ end
70
97
 
71
- if (OS.mac? && @platform.downcase == "ios")
72
- project_directory = ((GitPivotalTrackerIntegration::Util::Shell.exec 'find . -name "*.xcodeproj" 2>/dev/null').split /\/(?=[^\/]*$)/)[0]
98
+ # Create a new build commit, push to QA
99
+ puts Util::Git.create_commit( "Update version number to #{version_number} for release to UAT", story)
100
+ puts Util::Shell.exec "git push"
73
101
 
74
- # cd to the project_directory
75
- Dir.chdir(project_directory)
102
+ # Create release tag
103
+ #create_release_tag(version_number)
76
104
 
77
- # set project number in project file
78
- pwd
79
- puts GitPivotalTrackerIntegration::Util::Shell.exec "xcrun agvtool new-marketing-version #{version_number}"
105
+ #Created tag should be pushed to private Podspec repo
106
+ if has_spec_path? && @platform == "ios"
107
+ puts Util::Shell.exec "git checkout #{version_number}"
108
+ puts Util::Shell.exec "pod repo push V2PodSpecs #{@configuration.pconfig["spec"]["spec-path"]}"
109
+ puts Util::Shell.exec "git checkout develop"
110
+ end
80
111
 
81
- # cd back to the working_directory
82
- Dir.chdir(working_directory)
83
- end
84
-
85
- # Change spec version
86
- change_spec_version(version_number) if has_spec_path?
87
-
88
- # Create a new build commit, push to QA
89
- puts GitPivotalTrackerIntegration::Util::Git.create_commit( "Update version number to #{version_number} for delivery to QA", story)
90
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git push"
91
-
92
- # Create release tag
93
- create_release_tag(version_number) if has_spec_path?
94
-
95
- #Created tag should be pushed to private Podspec repo
96
- if has_spec_path? && @platform == "ios"
97
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout #{version_number}"
98
- puts GitPivotalTrackerIntegration::Util::Shell.exec "pod repo push V2PodSpecs #{@configuration.pconfig["spec"]["spec-path"]}"
99
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout develop"
100
- end
101
-
102
- #checkout develop branch
103
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout #{current_branch}"
104
-
105
- s_labels_string = story.labels
106
- s_labels = ""
107
- if (s_labels_string)
108
- s_labels = s_labels_string.split(",")
109
- s_labels << story.name
110
- s_labels_string = s_labels.uniq.join(",")
111
- else
112
- s_labels_string = story.name
113
- end
112
+ #checkout develop branch
113
+ puts Util::Shell.exec "git checkout #{current_branch}"
114
114
 
115
- puts "labels:#{s_labels_string}"
116
- story.update(:labels => s_labels_string)
115
+ #add story name as one of the labels for the story
116
+ labels = story.labels.map(&:name)
117
+ labels << story.name unless labels.include?(story.name)
118
+ puts "labels: #{labels.join(', ')}"
119
+ story.add_labels(*labels) unless labels.include?(story.name)
117
120
 
118
- i_stories = included_stories @project, story
119
- add_version_tag_to_stories i_stories, story
121
+ i_stories = included_stories @project, story
122
+ add_version_tag_to_stories i_stories, story
120
123
 
121
- end
122
-
123
- private
124
-
125
- CANDIDATE_STATES = %w(delivered unstarted).freeze
126
- CANDIDATE_TYPES = %w(bug chore feature release)
127
-
128
- def add_version_tag_to_stories(stories, release_story)
129
- all_stories = stories.dup
130
- all_stories << release_story
131
- puts "Included stories:\n"
132
- all_stories.each {|story|
133
- s_labels_string = story.labels
134
- s_labels = ""
135
- if (s_labels_string)
136
- s_labels = s_labels_string.split(",")
137
- s_labels << release_story.name
138
- s_labels_string = s_labels.uniq.join(",")
139
- else
140
- s_labels_string = release_story.name
141
124
  end
142
125
 
143
- unless story.labels.nil?
144
- if story.labels.scan(/b\d{1}/).size > story.labels.scan(/v\d{1}/).size
145
- story.update(:labels => s_labels_string)
146
- puts story.id
147
- end
148
- end
149
- }
150
- end
151
-
152
- def included_stories(project, release_story)
153
-
154
- criteria = {
155
- :current_state => CANDIDATE_STATES,
156
- :limit => 1000,
157
- :story_type => CANDIDATE_TYPES
158
- }
126
+ private
127
+
128
+ CANDIDATE_STATES = %w(delivered unstarted).freeze
129
+ CANDIDATE_TYPES = %w(bug chore feature release)
130
+
131
+ def add_version_tag_to_stories(stories, release_story)
132
+ all_stories = stories.dup
133
+ all_stories << release_story
134
+ puts "Included stories:\n"
135
+ all_stories.each {|story|
136
+ labels = story.labels.map(&:name)
137
+ origin_labels = labels.dup
138
+ labels << release_story.name
139
+ labels.uniq!
140
+
141
+ unless origin_labels.empty?
142
+ if origin_labels.to_s.scan(/b\d{1}/).size > origin_labels.to_s.scan(/v\d{1}/).size
143
+ story.add_labels(*labels)
144
+ puts "#{story.id} - #{story.name}"
145
+ end
146
+ end
147
+ }
148
+ end
159
149
 
150
+ def included_stories(project, release_story)
151
+ project.stories filter: "current_state:delivered type:bug,chore,feature -id:#{release_story.id}"
152
+ end
160
153
 
161
- candidates = project.stories.all criteria
154
+ def place_version_release(release_story)
155
+ not_accepted_releases = @project.stories(filter: "current_state:unstarted type:release")
156
+ not_accepted_releases_ids = not_accepted_releases.map(&:id)
157
+ unless (not_accepted_releases_ids.include?(release_story.id))
158
+ not_accepted_releases << release_story
159
+ not_accepted_releases_ids << release_story.id
160
+ end
161
+ specified_pt_story = @project.stories(filter: "current_state:unstarted,started,finished,delivered,rejected").first
162
+ last_accepted_release_story = @project.stories(filter: "current_state:accepted type:release").last
163
+ if not_accepted_releases.size > 1
164
+ release_story.after_id = not_accepted_releases[-2].id
165
+ release_story.save
166
+ elsif !specified_pt_story.nil?
167
+ release_story.before_id = specified_pt_story.id
168
+ release_story.save
169
+ end
170
+ end
162
171
 
163
- estimated_candidates = Array.new
164
- val_is_valid = true
165
-
166
- candidates.each do |val|
167
- val_is_valid = true
168
- if (val.id == release_story.id)
169
- next
172
+ def pull_out_rejected_stories(release_story)
173
+ rejected_stories = @project.stories(filter: "current_state:rejected type:bug,chore,feature")
174
+ rejected_stories.each do |rejected_story|
175
+ rejected_stories.after_id = release_story.id
176
+ rejected_stories.save
177
+ end
170
178
  end
171
- if (val.current_state != "delivered")
172
- val_is_valid = false
179
+
180
+ def has_spec_path?
181
+ config_file_path = "#{Util::Git.repository_root}/.v2gpti/config"
182
+ config_file_text = File.read(config_file_path)
183
+ spec_pattern_check = /spec-path(.*)=/.match("#{config_file_text}")
184
+ if spec_pattern_check.nil?
185
+ return false
186
+ else
187
+ spec_file_path = @configuration.pconfig["spec"]["spec-path"]
188
+ return !spec_file_path.nil?
189
+ end
173
190
  end
174
- if (val.story_type == "release")
175
- val_is_valid = false
191
+
192
+ def change_spec_version(version_number)
193
+ spec_file_path = "#{Util::Git.repository_root}/#{@configuration.pconfig["spec"]["spec-path"]}"
194
+ spec_file_text = File.read(spec_file_path)
195
+ File.open(spec_file_path, "w") {|file| file.puts spec_file_text.gsub(/(?<!_)version(.*)=(.*)['|"]/, "version = '#{version_number}'")}
176
196
  end
177
- if val_is_valid
178
- estimated_candidates << val
197
+
198
+ def create_release_tag(version_number)
199
+ Util::Shell.exec "git tag -a #{version_number} -m \"release #{version_number}\""
200
+ puts Util::Shell.exec "git push origin #{version_number}"
179
201
  end
202
+
180
203
  end
181
- candidates = estimated_candidates
182
- end
183
-
184
- def place_version_release(release_story)
185
- not_accepted_releases = nil
186
- not_accepted_releases_ids = nil
187
- not_accepted_releases = @project.stories.all(:current_state => 'unstarted', :story_type => 'release')
188
- not_accepted_releases_ids = Array.new
189
- not_accepted_releases.collect{|not_accepted_release| not_accepted_releases_ids.push not_accepted_release.id.to_i }
190
- unless (not_accepted_releases_ids.include?(release_story.id))
191
- not_accepted_releases << release_story
192
- not_accepted_releases_ids.clear
193
- not_accepted_releases.collect{|not_accepted_release| not_accepted_releases_ids.push not_accepted_release.id.to_i }
194
- end
195
- specified_pt_story = @project.stories.all(:current_state => ['unstarted', 'started', 'finished', 'delivered', 'rejected']).first
196
- last_accepted_release_story=@project.stories.all(:current_state => 'accepted', :story_type => 'release').last
197
- if not_accepted_releases.size > 1
198
- release_story.move(:after, not_accepted_releases[not_accepted_releases.size - 2])
199
- elsif !specified_pt_story.nil?
200
- release_story.move(:before, specified_pt_story)
201
- end
202
- end
203
-
204
- def pull_out_rejected_stories(release_story)
205
- rejected_stories=@project.stories.all(:current_state => ['rejected'], :story_type => ['bug', 'chore', 'feature'])
206
- rejected_stories.each{|rejected_story|
207
- rejected_story.move(:after, release_story)
208
- }
209
- end
210
-
211
- def has_spec_path?
212
- config_file_path = "#{GitPivotalTrackerIntegration::Util::Git.repository_root}/.v2gpti/config"
213
- config_file_text = File.read(config_file_path)
214
- spec_pattern_check = /spec-path(.*)=/.match("#{config_file_text}")
215
- if spec_pattern_check.nil?
216
- return false
217
- else
218
- spec_file_path = @configuration.pconfig["spec"]["spec-path"]
219
- if spec_file_path.nil?
220
- return false
221
- else
222
- return true
223
- end
224
- end
225
- end
226
-
227
- def change_spec_version(version_number)
228
- spec_file_path = "#{GitPivotalTrackerIntegration::Util::Git.repository_root}/#{@configuration.pconfig["spec"]["spec-path"]}"
229
- spec_file_text = File.read(spec_file_path)
230
- File.open(spec_file_path, "w") {|file| file.puts spec_file_text.gsub(/(?<!_)version(.*)=(.*)['|"]/, "version = '#{version_number}'")}
231
- end
232
-
233
- def create_release_tag(version_number)
234
- GitPivotalTrackerIntegration::Util::Shell.exec "git tag -a #{version_number} -m \"release #{version_number}\""
235
- puts GitPivotalTrackerIntegration::Util::Shell.exec "git push origin #{version_number}"
236
- end
237
204
 
205
+ end
238
206
  end
@@ -13,53 +13,50 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require 'git-pivotal-tracker-integration/command/base'
17
- require 'git-pivotal-tracker-integration/command/command'
18
- require 'git-pivotal-tracker-integration/util/git'
19
- require 'git-pivotal-tracker-integration/util/story'
20
- require 'git-pivotal-tracker-integration/version-update/gradle'
16
+ module GitPivotalTrackerIntegration
17
+ module Command
21
18
 
19
+ class Report < Base
22
20
 
23
- class GitPivotalTrackerIntegration::Command::Report < GitPivotalTrackerIntegration::Command::Base
21
+ V2GPTI_PROJECT_ID = 1067990
24
22
 
23
+ def run(args)
24
+ owned_by = 611593 # hard coded to Jeff Wolski for now
25
25
 
26
- def run(args)
26
+ $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}")
27
+ bug_title = nil
28
+ bug_title = args[0] if args.length == 1
27
29
 
28
- owned_by = "Jeff Wolski" # hard coded to Jeff Wolski for now
30
+ # puts bug_title
31
+ abort "\nUsage example:\n\n git report \"Issue running deliver command\" \n" if bug_title.nil? || bug_title.empty?
29
32
 
33
+ report_note = ""
34
+ while (report_note.nil? || report_note.empty?)
35
+ report_note = ask("Description of bug:")
36
+ end
30
37
 
31
- $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{GitPivotalTrackerIntegration::Util::Git.branch_name}")
32
- bug_title = nil
33
- if args.length == 1
34
- bug_title = args[0]
35
- end
36
- # puts bug_title
37
- if bug_title.nil? || bug_title.empty?
38
- abort "\nUsage example:\n\n git report \"Issue running deliver command\" \n"
39
- end
38
+ current_user = (Util::Shell.exec "git config user.name").chomp
39
+ bug_title = "User Reported - #{current_user} - #{bug_title}"
40
+ current_user_email = (Util::Shell.exec "git config user.email").chomp
41
+ bug_description = "#{@project.name}\n#{current_user_email}\n#{report_note}"
40
42
 
41
- report_note = ""
42
- while (report_note.nil? || report_note.empty?)
43
- report_note = ask("Description of bug:")
44
- end
43
+ project = @client.project(V2GPTI_PROJECT_ID)
44
+ attachment = project.add_attachment(self.logger_filename, 'text/plain')
45
45
 
46
- current_user = (GitPivotalTrackerIntegration::Util::Shell.exec "git config user.name").chomp
47
- bug_title = "User Reported - #{current_user} - #{bug_title}"
48
- current_user_email = (GitPivotalTrackerIntegration::Util::Shell.exec "git config user.email").chomp
49
- bug_description = "#{@project.name}\n#{current_user_email}\n#{report_note}"
46
+ story_params = {
47
+ :owner_ids => [owned_by],
48
+ :story_type => "bug",
49
+ :name => bug_title,
50
+ :description => bug_description,
51
+ :labels => ["userreported"]
52
+ }
50
53
 
51
- bug_story = PivotalTracker::Story.new
52
- bug_story.project_id = "1067990"
53
- bug_story.owned_by = owned_by
54
- bug_story.story_type = "bug"
55
- bug_story.name = bug_title
56
- bug_story.description = bug_description
57
- bug_story.labels = "userreported"
58
- uploaded_story = bug_story.create
59
-
60
- uploaded_story.upload_attachment(self.logger_filename)
61
- end
54
+ story = project.create_story story_params
62
55
 
56
+ story.add_comment_with_attachment('Log file', attachment)
57
+ end
63
58
 
59
+ end
64
60
 
61
+ end
65
62
  end