File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
examples/create_new_project Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/andygrunwald/go-gerrit"
7
+ )
8
+
9
+ func main () {
10
+ instance := fmt .Sprintf ("http://%s:8080" , "localhost" )
11
+ client , err := gerrit .NewClient (instance , nil )
12
+ if err != nil {
13
+ panic (err )
14
+ }
15
+
16
+ // Get your credentials
17
+ // For local development setups, go to
18
+ // http://localhost:8080/settings/#HTTPCredentials
19
+ // and click `GENERATE NEW PASSWORD`.
20
+ // Replace `secret` with your new value.
21
+ client .Authentication .SetBasicAuth ("admin" , "secret" )
22
+
23
+ gerritProject := "Example project to the moon"
24
+ gerritBranch := "main"
25
+
26
+ data := & gerrit.ProjectInput {
27
+ Name : gerritProject ,
28
+ Branches : []string {gerritBranch },
29
+ CreateEmptyCommit : true ,
30
+ }
31
+ projectInfo , _ , err := client .Projects .CreateProject (gerritProject , data )
32
+ if err != nil {
33
+ panic (err )
34
+ }
35
+
36
+ fmt .Printf ("Project '%s' created with ID '%+v'" , projectInfo .Name , projectInfo .ID )
37
+
38
+ // Project 'Example project to the moon' created with ID 'Example+project+to+the+moon'
39
+ }
You can’t perform that action at this time.
0 commit comments