-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpush.go
52 lines (42 loc) · 1.01 KB
/
push.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cmd
import (
"context"
"log"
"strings"
"github.com/ldez/prm/v3/config"
"github.com/ldez/prm/v3/local"
"github.com/ldez/prm/v3/types"
)
// Push push to the PR branch.
func Push(options *types.PushOptions) error {
// get configuration
confs, err := config.ReadFile()
if err != nil {
return err
}
repoDir, err := local.GetGitRepoRoot()
if err != nil {
return err
}
con, err := config.Find(confs, repoDir)
if err != nil {
return err
}
number, err := local.GetCurrentPRNumber(options.Number)
if err != nil {
return err
}
pr, err := con.FindPullRequests(number)
if err != nil {
return err
}
user, _, err := newGitHubClient(context.Background()).Users.Get(context.Background(), pr.Owner)
if err != nil {
return err
}
if strings.EqualFold(user.GetType(), "Organization") {
log.Println("WARNING: GitHub has introduced a 'silent' breaking change:")
log.Println("WARNING: it's now not possible to push on a fork's branch from a GitHub organization.")
}
return pr.Push(options.Force)
}