@@ -3,7 +3,6 @@ require "optionparser"
3
3
require "active_support"
4
4
require "active_support/all"
5
5
6
- @estimation = nil
7
6
@simulate = false
8
7
@issue_number = nil
9
8
44
43
45
44
OptionParser . new do |opts |
46
45
opts . banner = "Usage: pr [options] [title]\n Defaults: pr" + File ::SEPARATOR
47
- opts . on ( "-e" , "--estimation ESTIMATION" , Integer , "Estimated time in hours." ) do |e |
48
- @estimation = e . presence
49
- end
50
46
opts . on ( "-s" , "--simulate" , "Simulate the actions: prints out the write-commands instead of executing them, prefixed with ▶️ ." ) do
51
47
@simulate = true
52
48
end
@@ -63,11 +59,12 @@ branch += "#{@issue_number}_" if @issue_number
63
59
branch += name . parameterize . underscore
64
60
65
61
title = name
66
- title += " [#{ @estimation } ]" if @estimation
67
62
68
63
body_lines = [ ]
64
+ path = ".github/pull_request_template.md"
65
+ body_lines . push File . read ( path ) if File . exists? ( path )
69
66
body_lines . push "fixes ##{ @issue_number } " if @issue_number
70
- body = body_lines . join ( "\n " )
67
+ body = body_lines . join ( "\n \n " )
71
68
72
69
base_branch = current_branch
73
70
exit 1 unless [ "master" , "main" , "develop" ] . include? ( base_branch ) || confirm ( "Your base branch #{ base_branch } doesn't seem to be a common base branch name. Do you want to continue?" )
@@ -78,10 +75,13 @@ puts "Creating branch #{branch}"
78
75
sh "git checkout -b #{ branch } "
79
76
80
77
puts "Creating empty commit"
81
- sh "git commit -m 'initial commit for #{ title } ' --allow-empty"
78
+ commit_message = "initial commit for #{ title } "
79
+ commit_message += ", fixes ##{ @issue_number } " if @issue_number
80
+ sh "git commit -m '#{ commit_message } ' --allow-empty"
82
81
83
82
puts "Pushing to origin"
84
83
sh "git push -u origin #{ branch } "
85
84
86
85
puts "Creating pull request"
87
- sh "gh pr create --draft --title '#{ title } ' --body '#{ body } ' --base #{ base_branch } "
86
+ ENV [ "PR_BODY" ] = body_lines . join ( "\n " )
87
+ sh "gh pr create --draft --title '#{ title } ' --body \" $PR_BODY\" --base #{ base_branch } "
0 commit comments