Skip to content

Commit 85883e9

Browse files
committed
Saving work
1 parent 2d8fa04 commit 85883e9

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

src-tauri/src/main.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,25 +168,29 @@ async fn generate_ai_commit_message(
168168
}
169169

170170
#[tauri::command]
171-
async fn preview_alias(request: AliasRequest) -> Result<String, String> {
171+
async fn preview_alias(
172+
alias_name: String,
173+
commands: Vec<GitCommand>,
174+
ai_commit: bool,
175+
openai_api_key: Option<String>,
176+
) -> Result<String, String> {
172177
let mut command_parts = Vec::new();
173178

174-
for cmd in &request.commands {
179+
for cmd in &commands {
175180
if cmd.enabled {
176181
match cmd.name.as_str() {
177182
"add" => command_parts.push("git add .".to_string()),
178183
"commit" => {
179184
let message = cmd.parameters.get("message").unwrap_or(&"WIP".to_string()).clone();
180-
if request.ai_commit {
185+
if ai_commit {
181186
command_parts.push("echo 'Getting AI-generated commit message...'".to_string());
182187
command_parts.push("git commit -m \"$(echo 'AI message would be generated here')\"".to_string());
183188
} else {
184189
command_parts.push(format!("git commit -m \"{}\"", message));
185190
}
186191
},
187192
"push" => {
188-
let branch = cmd.parameters.get("branch").unwrap_or(&"origin".to_string()).clone();
189-
command_parts.push(format!("git push {}", branch));
193+
command_parts.push("git push".to_string());
190194
},
191195
"checkout" => {
192196
let branch = cmd.parameters.get("branch").unwrap_or(&"$1".to_string()).clone();
@@ -215,9 +219,14 @@ async fn preview_alias(request: AliasRequest) -> Result<String, String> {
215219
}
216220

217221
#[tauri::command]
218-
async fn create_alias(request: AliasRequest) -> AliasResponse {
222+
async fn create_alias(
223+
alias_name: String,
224+
commands: Vec<GitCommand>,
225+
ai_commit: bool,
226+
openai_api_key: Option<String>,
227+
) -> AliasResponse {
219228
// First validate the alias name
220-
let validation = validate_alias_name(request.alias_name.clone()).await;
229+
let validation = validate_alias_name(alias_name.clone()).await;
221230
if !validation.valid {
222231
return AliasResponse {
223232
success: false,
@@ -227,7 +236,12 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
227236
}
228237

229238
// Generate the alias command
230-
let alias_command = match preview_alias(request.clone()).await {
239+
let alias_command = match preview_alias(
240+
alias_name.clone(),
241+
commands.clone(),
242+
ai_commit,
243+
openai_api_key.clone(),
244+
).await {
231245
Ok(cmd) => cmd,
232246
Err(e) => {
233247
return AliasResponse {
@@ -243,7 +257,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
243257
.args(&[
244258
"config",
245259
"--global",
246-
&format!("alias.{}", request.alias_name),
260+
&format!("alias.{}", alias_name),
247261
&alias_command,
248262
])
249263
.output();
@@ -256,7 +270,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
256270
.args(&[
257271
"config",
258272
"--global",
259-
&format!("alias-tool.{}", request.alias_name),
273+
&format!("alias-tool.{}", alias_name),
260274
"git-alias-generator",
261275
])
262276
.output();
@@ -268,7 +282,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
268282

269283
AliasResponse {
270284
success: true,
271-
message: format!("Alias '{}' created successfully!", request.alias_name),
285+
message: format!("Alias '{}' created successfully!", alias_name),
272286
alias_command: Some(alias_command),
273287
}
274288
} else {

src/App.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const DEFAULT_COMMANDS: GitCommand[] = [
5050
name: "push",
5151
command: "git push",
5252
enabled: false,
53-
parameters: { branch: "origin" },
53+
parameters: {},
5454
},
5555
{
5656
name: "checkout",
@@ -75,7 +75,7 @@ const DEFAULT_COMMANDS: GitCommand[] = [
7575
const COMMAND_DESCRIPTIONS = {
7676
add: "Stage all changes in the current directory",
7777
commit: "Commit staged changes with a message",
78-
push: "Push commits to remote repository",
78+
push: "Push commits to the current branch",
7979
checkout: "Switch to a different branch",
8080
pull: "Pull latest changes from remote",
8181
cleanup: "Remove local branches that have been deleted on remote",
@@ -493,19 +493,6 @@ function App() {
493493
</>
494494
)}
495495

496-
{command.name === "push" && (
497-
<div className="param-group">
498-
<label className="param-label">Remote & Branch</label>
499-
<input
500-
type="text"
501-
className="param-input"
502-
value={command.parameters.branch || ""}
503-
onChange={(e) => updateCommandParameter(index, "branch", e.target.value)}
504-
placeholder="origin (or origin main, origin develop, etc.)"
505-
/>
506-
</div>
507-
)}
508-
509496
{command.name === "checkout" && (
510497
<div className="param-group">
511498
<label className="param-label">Branch Name</label>

0 commit comments

Comments
 (0)