@@ -6,20 +6,16 @@ use crate::schema::worktrees::dsl::worktrees;
66use diesel:: prelude:: { Insertable , Queryable , Selectable } ;
77use serde:: { Deserialize , Serialize } ;
88
9- #[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
10- pub enum WorktreeSource {
11- Branch ( String ) ,
12- }
13-
149#[ derive(
1510 Debug , Clone , PartialEq , Serialize , Deserialize , Queryable , Selectable , Insertable , Identifiable ,
1611) ]
1712#[ diesel( table_name = crate :: schema:: worktrees) ]
1813#[ diesel( check_for_backend( diesel:: sqlite:: Sqlite ) ) ]
14+ #[ diesel( primary_key( path) ) ]
1915pub struct Worktree {
20- pub id : String ,
21- pub base : String ,
2216 pub path : String ,
17+ pub reference : String ,
18+ pub base : String ,
2319 pub source : String ,
2420}
2521
@@ -41,16 +37,16 @@ impl WorktreesHandle<'_> {
4137 Ok ( ( ) )
4238 }
4339
44- pub fn get ( & mut self , id : & str ) -> Result < Option < Worktree > , diesel:: result:: Error > {
40+ pub fn get ( & mut self , path : & str ) -> Result < Option < Worktree > , diesel:: result:: Error > {
4541 let worktree = worktrees
46- . filter ( crate :: schema:: worktrees:: id . eq ( id ) )
42+ . filter ( crate :: schema:: worktrees:: path . eq ( path ) )
4743 . first :: < Worktree > ( & mut self . db . conn )
4844 . optional ( ) ?;
4945 Ok ( worktree)
5046 }
5147
52- pub fn delete ( & mut self , id : & str ) -> Result < ( ) , diesel:: result:: Error > {
53- diesel:: delete ( worktrees. filter ( crate :: schema:: worktrees:: id . eq ( id ) ) )
48+ pub fn delete ( & mut self , path : & str ) -> Result < ( ) , diesel:: result:: Error > {
49+ diesel:: delete ( worktrees. filter ( crate :: schema:: worktrees:: path . eq ( path ) ) )
5450 . execute ( & mut self . db . conn ) ?;
5551 Ok ( ( ) )
5652 }
0 commit comments