class AssistedWorkflow::Addons::Git
Constants
- DESCRIPTION_LIMIT
Public Class Methods
new(output, options = {})
click to toggle source
Calls superclass method
AssistedWorkflow::Addons::Base::new
# File lib/assisted_workflow/addons/git.rb, line 12 def initialize(output, options = {}) super @command_options = {:raise_error => true}.merge(options) end
Public Instance Methods
check_merged!()
click to toggle source
check if current branch is merged into master
# File lib/assisted_workflow/addons/git.rb, line 57 def check_merged! check_everything_commited! branch = current_branch git "checkout master" git "pull --rebase" merged = git("branch --merged").include?(branch) git "checkout #{branch}" unless merged raise AssistedWorkflow::Error, "this branch is not merged into master" end merged end
create_story_branch(story, username)
click to toggle source
creates a new git branch based on story attributes the branch name format is:
> story_onwer_username.story_id.story_name¶ ↑
# File lib/assisted_workflow/addons/git.rb, line 20 def create_story_branch(story, username) log "creating the feature branch" branch = branch_name(story, username) git "checkout -b #{branch}" # git "push --set-upstream origin #{branch}" end
current_branch()
click to toggle source
returns the current local branch name
# File lib/assisted_workflow/addons/git.rb, line 45 def current_branch git("rev-parse --abbrev-ref HEAD", :silent => true) end
current_story_id()
click to toggle source
returns the current story id based on branch name
# File lib/assisted_workflow/addons/git.rb, line 40 def current_story_id current_branch.split(".")[1] end
rebase_and_push()
click to toggle source
run all the git steps required for a clean pull request
# File lib/assisted_workflow/addons/git.rb, line 28 def rebase_and_push log "preparing local branch" check_everything_commited! branch = current_branch git "checkout master" git "pull --rebase" git "checkout #{branch}" git "rebase master" git "push -u -f origin #{branch}" end
remove_branch()
click to toggle source
removes current branch and its remote version
# File lib/assisted_workflow/addons/git.rb, line 71 def remove_branch log "removing local and remote feature branches" branch = current_branch git "push origin :#{branch}", :raise_error => false git "checkout master" git "branch -D #{branch}" end
repository()
click to toggle source
returns the repository name assigned to origin following the format: owner/project
# File lib/assisted_workflow/addons/git.rb, line 51 def repository url = git("config --get remote.origin.url", :error => "cannot find 'origin' remote repository url") url.gsub("git@github.com:", "").gsub("https://github.com/", "").gsub(/\.git$/, "").chomp end