Class: Fgi::GitService
- Inherits:
-
Object
- Object
- Fgi::GitService
- Extended by:
- HttpRequests
- Defined in:
- lib/fgi/git_service.rb
Class Method Summary collapse
-
.fix_issue(options) ⇒ Object
All the process initiated by the issue fix => Commiting with a ‘Fix #<id>’ message => Pushing the current branch to the remote repo => Return to the default project branch.
-
.new_issue(title:, options: {}) ⇒ Object
All the process initiated by the issue creation => Create issue => Create a new branch from the default one => Set the issue estimation time.
-
.services ⇒ Array<String>
An array containing all the git services available.
Methods included from HttpRequests
Class Method Details
.fix_issue(options) ⇒ Object
All the process initiated by the issue fix
=> Commiting with a 'Fix #<id>'
=> Pushing the current branch to the remote repo
=> Return to the default project branch
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fgi/git_service.rb', line 50 def fix_issue() current_branch = `git branch | grep '*'`.gsub('* ', '').chomp if ISSUES[current_branch].nil? puts "We could not find any issues to fix on your current branch (#{current_branch})." exit! end git_remote = ask_for_remote `git add .` puts "Are you sure to want to close the issue #{ISSUES[current_branch][:title]} ?" begin input = STDIN.gets.chomp if %w[y yes].include?(input) = "Fix ##{ISSUES[current_branch][:id]}" += " - #{options[:fix_message]}" unless [:fix_message].nil? `git commit -a --allow-empty -m '#{commit_message}'` `git push #{git_remote} HEAD` `git branch -u #{git_remote}/#{name}` # Define the upstream branch `git checkout #{CONFIG[:default_branch]}` # Be sure to be on the default branch. remove_issue(current_branch) puts "Congrat's ! You're now back to work on the default branch (#{CONFIG[:default_branch]})" end rescue Interrupt puts %q"Why did you killed me ? :'(" exit! end end |
.new_issue(title:, options: {}) ⇒ Object
All the process initiated by the issue creation
=> Create issue
=> Create a new branch from the default one
=> Set the issue estimation time
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fgi/git_service.rb', line 23 def new_issue(title:, options: {}) git_service = CONFIG[:git_service_class].new title = get_issue_title if title.nil? response = create_issue(title: title, git_service: git_service) if CONFIG[:default_branch].nil? puts "\n/!\\ FGI IS NOT UP-TO-DATE /!\\" puts 'We are not able to create and switch you to the new branch.' puts 'Delete .config.fgi.yml and reconfigure fgi by running `fgi config`' elsif !response['iid'].nil? branch_name = snakify(title) branch_name = "#{options[:prefix]}/#{branch_name}" unless [:prefix].nil? save_issue(branch: branch_name, id: response['iid'], title: response['title'].tr("'", ' ')) create_branch(name: branch_name, from_current: [:from_current]) unless [:later] set_issue_estimation( issue_id: response['iid'], estimation: [:estimate], git_service: git_service ) end end |
.services ⇒ Array<String>
Returns an array containing all the git services available.
9 10 11 12 13 14 15 |
# File 'lib/fgi/git_service.rb', line 9 def services services = [] Dir.entries("#{File.dirname(__FILE__)}/git_services").each do |service| services << service.gsub(/.rb/, '').to_sym unless %w[. ..].include?(service) end services end |