1package git2go
2
3// Action represents an action taken to build a commit.
4type Action interface{ action() }
5
6// isAction is used ensuring type safety for actions.
7type isAction struct{}
8
9func (isAction) action() {}
10
11// ChangeFileMode sets a file's mode to either regular or executable file.
12// FileNotFoundError is returned when attempting to change a non-existent
13// file's mode.
14type ChangeFileMode struct {
15	isAction
16	// Path is the path of the whose mode to change.
17	Path string
18	// ExecutableMode indicates whether the file mode should be changed to executable or not.
19	ExecutableMode bool
20}
21
22// CreateDirectory creates a directory in the given path with a '.gitkeep' file inside.
23// FileExistsError is returned if a file already exists at the provided path.
24// DirectoryExistsError is returned if a directory already exists at the provided
25// path.
26type CreateDirectory struct {
27	isAction
28	// Path is the path of the directory to create.
29	Path string
30}
31
32// CreateFile creates a file using the provided path, mode and oid as the blob.
33// FileExistsError is returned if a file exists at the given path.
34type CreateFile struct {
35	isAction
36	// Path is the path of the file to create.
37	Path string
38	// ExecutableMode indicates whether the file mode should be executable or not.
39	ExecutableMode bool
40	// OID is the id of the object that contains the content of the file.
41	OID string
42}
43
44// DeleteFile deletes a file or a directory from the provided path.
45// FileNotFoundError is returned if the file does not exist.
46type DeleteFile struct {
47	isAction
48	// Path is the path of the file to delete.
49	Path string
50}
51
52// MoveFile moves a file or a directory to the new path.
53// FileNotFoundError is returned if the file does not exist.
54type MoveFile struct {
55	isAction
56	// Path is the path of the file to move.
57	Path string
58	// NewPath is the new path of the file.
59	NewPath string
60	// OID is the id of the object that contains the content of the file. If set,
61	// the file contents are updated to match the object, otherwise the file keeps
62	// the existing content.
63	OID string
64}
65
66// UpdateFile updates a file at the given path to point to the provided
67// OID. FileNotFoundError is returned if the file does not exist.
68type UpdateFile struct {
69	isAction
70	// Path is the path of the file to update.
71	Path string
72	// OID is the id of the object that contains the new content of the file.
73	OID string
74}
75