mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Add commit name and commit email to workspace model
This commit is contained in:
@@ -23,11 +23,11 @@ func (db *database) CreateWorkspace(workspace *models.Workspace) error {
|
|||||||
INSERT INTO workspaces (
|
INSERT INTO workspaces (
|
||||||
user_id, name, theme, auto_save, show_hidden_files,
|
user_id, name, theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template, git_commit_name, git_commit_email
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
workspace.UserID, workspace.Name, workspace.Theme, workspace.AutoSave, workspace.ShowHiddenFiles,
|
workspace.UserID, workspace.Name, workspace.Theme, workspace.AutoSave, workspace.ShowHiddenFiles,
|
||||||
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, encryptedToken,
|
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, encryptedToken,
|
||||||
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate,
|
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate, workspace.GitCommitName, workspace.GitCommitEmail,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -51,7 +51,7 @@ func (db *database) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
|||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save, show_hidden_files,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template, git_commit_name, git_commit_email
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
WHERE id = ?`,
|
WHERE id = ?`,
|
||||||
id,
|
id,
|
||||||
@@ -59,7 +59,7 @@ func (db *database) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
|||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate, &workspace.GitCommitName, &workspace.GitCommitEmail,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -84,7 +84,8 @@ func (db *database) GetWorkspaceByName(userID int, workspaceName string) (*model
|
|||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save, show_hidden_files,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template,
|
||||||
|
git_commit_name, git_commit_email
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
WHERE user_id = ? AND name = ?`,
|
WHERE user_id = ? AND name = ?`,
|
||||||
userID, workspaceName,
|
userID, workspaceName,
|
||||||
@@ -92,7 +93,7 @@ func (db *database) GetWorkspaceByName(userID int, workspaceName string) (*model
|
|||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate, &workspace.GitCommitName, &workspace.GitCommitEmail,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -127,7 +128,9 @@ func (db *database) UpdateWorkspace(workspace *models.Workspace) error {
|
|||||||
git_user = ?,
|
git_user = ?,
|
||||||
git_token = ?,
|
git_token = ?,
|
||||||
git_auto_commit = ?,
|
git_auto_commit = ?,
|
||||||
git_commit_msg_template = ?
|
git_commit_msg_template = ?,
|
||||||
|
git_commit_name = ?,
|
||||||
|
git_commit_email = ?
|
||||||
WHERE id = ? AND user_id = ?`,
|
WHERE id = ? AND user_id = ?`,
|
||||||
workspace.Name,
|
workspace.Name,
|
||||||
workspace.Theme,
|
workspace.Theme,
|
||||||
@@ -139,6 +142,8 @@ func (db *database) UpdateWorkspace(workspace *models.Workspace) error {
|
|||||||
encryptedToken,
|
encryptedToken,
|
||||||
workspace.GitAutoCommit,
|
workspace.GitAutoCommit,
|
||||||
workspace.GitCommitMsgTemplate,
|
workspace.GitCommitMsgTemplate,
|
||||||
|
workspace.GitCommitName,
|
||||||
|
workspace.GitCommitEmail,
|
||||||
workspace.ID,
|
workspace.ID,
|
||||||
workspace.UserID,
|
workspace.UserID,
|
||||||
)
|
)
|
||||||
@@ -152,7 +157,8 @@ func (db *database) GetWorkspacesByUserID(userID int) ([]*models.Workspace, erro
|
|||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save, show_hidden_files,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template,
|
||||||
|
git_commit_name, git_commit_email
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
WHERE user_id = ?`,
|
WHERE user_id = ?`,
|
||||||
userID,
|
userID,
|
||||||
@@ -171,6 +177,7 @@ func (db *database) GetWorkspacesByUserID(userID int) ([]*models.Workspace, erro
|
|||||||
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
|
&workspace.GitCommitName, &workspace.GitCommitEmail,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -201,7 +208,9 @@ func (db *database) UpdateWorkspaceSettings(workspace *models.Workspace) error {
|
|||||||
git_user = ?,
|
git_user = ?,
|
||||||
git_token = ?,
|
git_token = ?,
|
||||||
git_auto_commit = ?,
|
git_auto_commit = ?,
|
||||||
git_commit_msg_template = ?
|
git_commit_msg_template = ?,
|
||||||
|
git_commit_name = ?,
|
||||||
|
git_commit_email = ?
|
||||||
WHERE id = ?`,
|
WHERE id = ?`,
|
||||||
workspace.Theme,
|
workspace.Theme,
|
||||||
workspace.AutoSave,
|
workspace.AutoSave,
|
||||||
@@ -212,6 +221,8 @@ func (db *database) UpdateWorkspaceSettings(workspace *models.Workspace) error {
|
|||||||
workspace.GitToken,
|
workspace.GitToken,
|
||||||
workspace.GitAutoCommit,
|
workspace.GitAutoCommit,
|
||||||
workspace.GitCommitMsgTemplate,
|
workspace.GitCommitMsgTemplate,
|
||||||
|
workspace.GitCommitName,
|
||||||
|
workspace.GitCommitEmail,
|
||||||
workspace.ID,
|
workspace.ID,
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
@@ -261,7 +272,8 @@ func (db *database) GetAllWorkspaces() ([]*models.Workspace, error) {
|
|||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save, show_hidden_files,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template,
|
||||||
|
git_commit_name, git_commit_email
|
||||||
FROM workspaces`,
|
FROM workspaces`,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -278,6 +290,7 @@ func (db *database) GetAllWorkspaces() ([]*models.Workspace, error) {
|
|||||||
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
|
&workspace.GitCommitName, &workspace.GitCommitEmail,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ func TestWorkspaceOperations(t *testing.T) {
|
|||||||
GitToken: "secret-token",
|
GitToken: "secret-token",
|
||||||
GitAutoCommit: true,
|
GitAutoCommit: true,
|
||||||
GitCommitMsgTemplate: "${action} ${filename}",
|
GitCommitMsgTemplate: "${action} ${filename}",
|
||||||
|
GitCommitName: "Test User",
|
||||||
|
GitCommitEmail: "test@example.com",
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
@@ -244,6 +246,8 @@ func TestWorkspaceOperations(t *testing.T) {
|
|||||||
workspace.GitToken = "new-token"
|
workspace.GitToken = "new-token"
|
||||||
workspace.GitAutoCommit = true
|
workspace.GitAutoCommit = true
|
||||||
workspace.GitCommitMsgTemplate = "custom ${filename}"
|
workspace.GitCommitMsgTemplate = "custom ${filename}"
|
||||||
|
workspace.GitCommitName = "Test User"
|
||||||
|
workspace.GitCommitEmail = "test@example.com"
|
||||||
|
|
||||||
if err := database.UpdateWorkspace(workspace); err != nil {
|
if err := database.UpdateWorkspace(workspace); err != nil {
|
||||||
t.Fatalf("failed to update workspace: %v", err)
|
t.Fatalf("failed to update workspace: %v", err)
|
||||||
@@ -424,6 +428,12 @@ func verifyWorkspace(t *testing.T, actual, expected *models.Workspace) {
|
|||||||
if actual.GitCommitMsgTemplate != expected.GitCommitMsgTemplate {
|
if actual.GitCommitMsgTemplate != expected.GitCommitMsgTemplate {
|
||||||
t.Errorf("GitCommitMsgTemplate = %v, want %v", actual.GitCommitMsgTemplate, expected.GitCommitMsgTemplate)
|
t.Errorf("GitCommitMsgTemplate = %v, want %v", actual.GitCommitMsgTemplate, expected.GitCommitMsgTemplate)
|
||||||
}
|
}
|
||||||
|
if actual.GitCommitName != expected.GitCommitName {
|
||||||
|
t.Errorf("GitCommitName = %v, want %v", actual.GitCommitName, expected.GitCommitName)
|
||||||
|
}
|
||||||
|
if actual.GitCommitEmail != expected.GitCommitEmail {
|
||||||
|
t.Errorf("GitCommitEmail = %v, want %v", actual.GitCommitEmail, expected.GitCommitEmail)
|
||||||
|
}
|
||||||
if actual.CreatedAt.IsZero() {
|
if actual.CreatedAt.IsZero() {
|
||||||
t.Error("CreatedAt should not be zero")
|
t.Error("CreatedAt should not be zero")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ type Workspace struct {
|
|||||||
GitToken string `json:"gitToken" validate:"required_if=GitEnabled true"`
|
GitToken string `json:"gitToken" validate:"required_if=GitEnabled true"`
|
||||||
GitAutoCommit bool `json:"gitAutoCommit"`
|
GitAutoCommit bool `json:"gitAutoCommit"`
|
||||||
GitCommitMsgTemplate string `json:"gitCommitMsgTemplate"`
|
GitCommitMsgTemplate string `json:"gitCommitMsgTemplate"`
|
||||||
|
GitCommitName string `json:"gitCommitName"`
|
||||||
|
GitCommitEmail string `json:"gitCommitEmail" validate:"required_if=GitEnabled true,email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates the workspace struct
|
// Validate validates the workspace struct
|
||||||
|
|||||||
Reference in New Issue
Block a user