-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (43 loc) · 1.19 KB
/
main.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
53
54
55
package main
import (
"fmt"
"os"
"strconv"
"github.com/atolycs/gh-get-private-email/internal/version"
"github.com/atolycs/gh-get-private-email/pkg/config"
"github.com/atolycs/gh-get-private-email/pkg/validate"
"github.com/cli/go-gh/v2/pkg/api"
)
func main() {
// fmt.Println("hi world, this is the gh-get-private-email extension!")
version.CallVersion()
client, err := api.DefaultRESTClient()
if err != nil {
fmt.Println(err)
return
}
response := struct {
Login string
Id int
}{}
err = client.Get("user", &response)
if err != nil {
fmt.Println(err)
return
}
account_id := strconv.Itoa(response.Id)
account_name := response.Login
email_templates := "@users.noreply.github.com"
commit_address := account_id + "+" + account_name + email_templates
fmt.Printf("Getting commit address: %s\n", commit_address)
fmt.Println("Setting commit address...")
if _, err := validate.IsRepository(); err != nil {
fmt.Println("Not git repository")
os.Exit(1)
}
config.Userset(commit_address)
fmt.Println("Setup complete")
// fmt.Printf("running as %s\n", response.Login)
}
// For more examples of using go-gh, see:
// https://github.com/cli/go-gh/blob/trunk/example_gh_test.go