This repository was archived by the owner on Jun 8, 2019. It is now read-only.
File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package gitea
6
+
7
+ import (
8
+ "bytes"
9
+ "encoding/json"
10
+ "fmt"
11
+ )
12
+
13
+ // ListForks list a repository's forks
14
+ func (c * Client ) ListForks (user , repo string ) ([]* Repository , error ) {
15
+ forks := make ([]* Repository , 10 )
16
+ err := c .getParsedResponse ("GET" ,
17
+ fmt .Sprintf ("/repos/%s/%s/forks" , user , repo ),
18
+ nil , nil , & forks )
19
+ return forks , err
20
+ }
21
+
22
+ // CreateForkOption options for creating a fork
23
+ type CreateForkOption struct {
24
+ Organization * string `json:"organization"`
25
+ }
26
+
27
+ // CreateFork create a fork of a repository
28
+ func (c * Client ) CreateFork (user , repo string , form CreateForkOption ) (* Repository , error ) {
29
+ body , err := json .Marshal (form )
30
+ if err != nil {
31
+ return nil , err
32
+ }
33
+ fork := new (Repository )
34
+ err = c .getParsedResponse ("POST" ,
35
+ fmt .Sprintf ("/repos/%s/%s/forks" , user , repo ),
36
+ jsonHeader , bytes .NewReader (body ), & fork )
37
+ return fork , err
38
+ }
You can’t perform that action at this time.
0 commit comments