Skip to content

Commit 1accefb

Browse files
committed
🔧 Refactored Git handling & query building functions.
1 parent 45036ae commit 1accefb

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

‎src/git.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,30 +146,4 @@ impl Git {
146146

147147
Ok(status_value)
148148
}
149-
150-
pub fn add_all(self: &Self) {
151-
self.repo
152-
.index()
153-
.unwrap()
154-
.add_all(&["."], git2::IndexAddOption::DEFAULT, None)
155-
.unwrap();
156-
}
157-
158-
pub fn commit(self: &Self, message: String) {
159-
let mut index = self.repo.index().unwrap();
160-
let oid = index.write_tree().unwrap();
161-
let signature = self.repo.signature().unwrap();
162-
let parent_commit = self.repo.head().unwrap().peel_to_commit().unwrap();
163-
let tree = self.repo.find_tree(oid).unwrap();
164-
self.repo
165-
.commit(
166-
Some("HEAD"),
167-
&signature,
168-
&signature,
169-
&message,
170-
&tree,
171-
&[&parent_commit],
172-
)
173-
.unwrap();
174-
}
175149
}

‎src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use colored::Colorize;
1212
use gpt_api::query;
1313

1414
use crate::{
15-
command_utils::parse_command,
15+
command_utils::{parse_command, run_commands},
1616
git::{build_commands, Git},
1717
utils::{check_for_update, get_executable_name},
1818
};
@@ -190,8 +190,7 @@ async fn main() {
190190
std::io::stdin().read_line(&mut input).unwrap();
191191
println!("");
192192
if input.trim() == "y" || input.trim() == "Y" || input.trim() == "" {
193-
git.add_all();
194-
git.commit(result);
193+
run_commands(&result);
195194
std::process::exit(0);
196195
} else if input.trim() == "n" || input.trim() == "N" {
197196
println!("{}", "Aborted".red());

0 commit comments

Comments
 (0)