@@ -22,6 +22,16 @@ type FileOptions struct {
22
22
Signoff bool `json:"signoff"`
23
23
}
24
24
25
+ func (f * FileOptions ) GetFileOptions () * FileOptions {
26
+ return f
27
+ }
28
+
29
+ type FileOptionInterface interface {
30
+ GetFileOptions () * FileOptions
31
+ }
32
+
33
+ var _ FileOptionInterface = (* FileOptions )(nil )
34
+
25
35
// CreateFileOptions options for creating files
26
36
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
27
37
type CreateFileOptions struct {
@@ -31,11 +41,6 @@ type CreateFileOptions struct {
31
41
ContentBase64 string `json:"content"`
32
42
}
33
43
34
- // Branch returns branch name
35
- func (o * CreateFileOptions ) Branch () string {
36
- return o .FileOptions .BranchName
37
- }
38
-
39
44
// DeleteFileOptions options for deleting files (used for other File structs below)
40
45
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
41
46
type DeleteFileOptions struct {
@@ -45,11 +50,6 @@ type DeleteFileOptions struct {
45
50
SHA string `json:"sha" binding:"Required"`
46
51
}
47
52
48
- // Branch returns branch name
49
- func (o * DeleteFileOptions ) Branch () string {
50
- return o .FileOptions .BranchName
51
- }
52
-
53
53
// UpdateFileOptions options for updating files
54
54
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
55
55
type UpdateFileOptions struct {
@@ -61,25 +61,21 @@ type UpdateFileOptions struct {
61
61
FromPath string `json:"from_path" binding:"MaxSize(500)"`
62
62
}
63
63
64
- // Branch returns branch name
65
- func (o * UpdateFileOptions ) Branch () string {
66
- return o .FileOptions .BranchName
67
- }
68
-
69
- // FIXME: ChangeFileOperation.SHA is NOT required for update or delete if last commit is provided in the options.
64
+ // FIXME: there is no LastCommitID in FileOptions, actually it should be an alternative to the SHA in ChangeFileOperation
70
65
71
66
// ChangeFileOperation for creating, updating or deleting a file
72
67
type ChangeFileOperation struct {
73
- // indicates what to do with the file
68
+ // indicates what to do with the file: "create" for creating a new file, "update" for updating an existing file,
69
+ // "upload" for creating or updating a file, "rename" for renaming a file, and "delete" for deleting an existing file.
74
70
// required: true
75
- // enum: create,update,delete
71
+ // enum: create,update,upload,rename, delete
76
72
Operation string `json:"operation" binding:"Required"`
77
73
// path to the existing or new file
78
74
// required: true
79
75
Path string `json:"path" binding:"Required;MaxSize(500)"`
80
- // new or updated file content, must be base64 encoded
76
+ // new or updated file content, it must be base64 encoded
81
77
ContentBase64 string `json:"content"`
82
- // sha is the SHA for the file that already exists, required for update or delete
78
+ // sha is the SHA for the file that already exists, required for changing existing files
83
79
SHA string `json:"sha"`
84
80
// old path of the file to move
85
81
FromPath string `json:"from_path"`
@@ -94,16 +90,6 @@ type ChangeFilesOptions struct {
94
90
Files []* ChangeFileOperation `json:"files" binding:"Required"`
95
91
}
96
92
97
- // Branch returns branch name
98
- func (o * ChangeFilesOptions ) Branch () string {
99
- return o .FileOptions .BranchName
100
- }
101
-
102
- // FileOptionInterface provides a unified interface for the different file options
103
- type FileOptionInterface interface {
104
- Branch () string
105
- }
106
-
107
93
// ApplyDiffPatchFileOptions options for applying a diff patch
108
94
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
109
95
type ApplyDiffPatchFileOptions struct {
0 commit comments