@@ -22,6 +22,16 @@ type FileOptions struct {
2222 Signoff bool `json:"signoff"`
2323}
2424
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+
2535// CreateFileOptions options for creating files
2636// 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)
2737type CreateFileOptions struct {
@@ -31,11 +41,6 @@ type CreateFileOptions struct {
3141 ContentBase64 string `json:"content"`
3242}
3343
34- // Branch returns branch name
35- func (o * CreateFileOptions ) Branch () string {
36- return o .FileOptions .BranchName
37- }
38-
3944// DeleteFileOptions options for deleting files (used for other File structs below)
4045// 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)
4146type DeleteFileOptions struct {
@@ -45,11 +50,6 @@ type DeleteFileOptions struct {
4550 SHA string `json:"sha" binding:"Required"`
4651}
4752
48- // Branch returns branch name
49- func (o * DeleteFileOptions ) Branch () string {
50- return o .FileOptions .BranchName
51- }
52-
5353// UpdateFileOptions options for updating files
5454// 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)
5555type UpdateFileOptions struct {
@@ -61,25 +61,21 @@ type UpdateFileOptions struct {
6161 FromPath string `json:"from_path" binding:"MaxSize(500)"`
6262}
6363
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
7065
7166// ChangeFileOperation for creating, updating or deleting a file
7267type 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.
7470 // required: true
75- // enum: create,update,delete
71+ // enum: create,update,upload,rename, delete
7672 Operation string `json:"operation" binding:"Required"`
7773 // path to the existing or new file
7874 // required: true
7975 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
8177 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
8379 SHA string `json:"sha"`
8480 // old path of the file to move
8581 FromPath string `json:"from_path"`
@@ -94,16 +90,6 @@ type ChangeFilesOptions struct {
9490 Files []* ChangeFileOperation `json:"files" binding:"Required"`
9591}
9692
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-
10793// ApplyDiffPatchFileOptions options for applying a diff patch
10894// 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)
10995type ApplyDiffPatchFileOptions struct {
0 commit comments