-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
024fc51
commit 5a2c9c2
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/andygrunwald/go-gerrit" | ||
) | ||
|
||
func main() { | ||
instance := fmt.Sprintf("http://%s:8080", "localhost") | ||
client, err := gerrit.NewClient(instance, nil) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Get your credentials | ||
// For local development setups, go to | ||
// http://localhost:8080/settings/#HTTPCredentials | ||
// and click `GENERATE NEW PASSWORD`. | ||
// Replace `secret` with your new value. | ||
client.Authentication.SetBasicAuth("admin", "secret") | ||
|
||
gerritProject := "Example project to the moon" | ||
gerritBranch := "main" | ||
|
||
data := &gerrit.ProjectInput{ | ||
Name: gerritProject, | ||
Branches: []string{gerritBranch}, | ||
CreateEmptyCommit: true, | ||
} | ||
projectInfo, _, err := client.Projects.CreateProject(gerritProject, data) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Printf("Project '%s' created with ID '%+v'", projectInfo.Name, projectInfo.ID) | ||
|
||
// Project 'Example project to the moon' created with ID 'Example+project+to+the+moon' | ||
} |