lib/git_flower/story.rb in git_flower-0.1.1 vs lib/git_flower/story.rb in git_flower-0.1.2

- old
+ new

@@ -4,15 +4,13 @@ require_relative 'git_repository' require_relative 'pivotal_project' module GitFlower class Story - def initialize(story_name:, labels:, project_id:, pivotal_token:) + def initialize(story_name:, labels:) @story_name = story_name @labels = Array(labels) - @project_id = project_id - @pivotal_token = pivotal_token end def create_story!(type) if type.nil? || !["feature", "hotfix"].include?(type) raise ArgumentError, "You need to specify that your story is a feature or a hotfix" @@ -24,16 +22,18 @@ owner_usernames: derive_story_owners) puts "Your pivotal story is https://www.pivotaltracker.com/story/show/#{story.id}" puts "Creating #{type} branch for #{story_name}" - `git flow #{type} start #{branch_name(story.id)}` + GitRepository. + new(Dir.pwd). + start_branch(name: story_name, id: story.id, type: type) end private - attr_reader :story_name, :labels, :project_id, :pivotal_token + attr_reader :story_name, :labels def validate_environment_and_arguments! if env_variable_undefined?(story_name) raise ArgumentError, "please pass a pivotal story name" end @@ -53,10 +53,18 @@ def pivotal_project PivotalProject.new(pivotal_token, project_id) end + def pivotal_token + ENV['PIVOTAL_TOKEN'] + end + + def project_id + ENV['PIVOTAL_PROJECT_ID'] + end + def derive_story_owners begin hitch_config = YAML.load_file("#{ENV['HOME']}/.hitchrc") if hitch_config[:current_pair].empty? Array(ENV['USER']) @@ -64,12 +72,8 @@ hitch_config[:current_pair] end rescue Array(ENV['USER']) end - end - - def branch_name(story_id) - Shellwords.shellescape("#{story_id}-#{story_name.parameterize}") end end end