Class: Aid::Scripts::Begin

Inherits:
Aid::Script show all
Includes:
GitConfig, GitStaged
Defined in:
lib/aid/scripts/begin.rb

Constant Summary

Constants included from Colorize

Colorize::COLOR_CODES

Instance Attribute Summary

Attributes inherited from Aid::Script

#argv

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GitStaged

#check_for_staged_files!

Methods included from GitConfig

#git_config, #prompt, #prompt_for_config!

Methods inherited from Aid::Script

#description, #exit_code, #exit_with_help!, #help, #initialize, name, #project_root, run, #step, #system!

Methods included from Inheritable

included

Methods included from Colorize

colorize, included

Constructor Details

This class inherits a constructor from Aid::Script

Class Method Details

.descriptionObject



15
16
17
# File 'lib/aid/scripts/begin.rb', line 15

def self.description
  "Starts a new Asana story"
end

.helpObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/aid/scripts/begin.rb', line 19

def self.help
  <<~HELP
    Fill me in.
    aid begin:
      Starts a story on Asana, moves it into the Work In Progress column,
      and opens a pull request on GitHub for you.
    Usage:
      aid begin "https://app.asana.com/0/1135298954694367/1135903276459289/f"
  HELP
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
76
# File 'lib/aid/scripts/begin.rb', line 30

def run
  check_for_hub!
  check_for_hub_credentials!

  prompt_for_config!(
    "asana.personal-access-token",
    "Enter your personal access token",
    <<~EOF
      1. Visit https://app.asana.com/0/developer-console
      2. Click "+ New access token" under "Personal access tokens"
      3. Give the token a name
      4. Copy the token and paste it back here.
    EOF
  )

  prompt_for_config!(
    "github.user",
    "Enter your GitHub username",
    <<~EOF
      1. Visit https://github.com and sign in
      2. Find the GitHub username you use and paste it in here
    EOF
  )

  set_asana_project_id_if_needed!
  check_for_existing_branch!
  ensure_base_branch_is_ok!

  step "Starting '#{asana_task.name}' on Asana" do
    start_task
  end

  step "Creating local branch off '#{base_branch}'" do
    check_for_staged_files!
    reset_hard_to_base_branch!
    create_git_branch!
    make_empty_commit!
  end

  step "Pushing to Github" do
    push_branch_to_github!
  end

  step "Opening pull request on Github" do
    open_pull_request_on_github!
  end
end