File tree Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -124,18 +124,34 @@ impl AppGit {
124
124
for delta in diff. deltas ( ) {
125
125
let file = delta. new_file ( ) ;
126
126
if let Some ( path) = file. path ( ) {
127
+ if let Some ( Some ( parent_dir) ) = path. parent ( ) . map ( |x|x. to_str ( ) . map ( |x|x. to_string ( ) ) ) {
128
+ if !has. contains ( & parent_dir. to_string ( ) ) {
129
+ if let Some ( item) = state_tree. iter ( ) . find ( |x| x. to_path ( ) . starts_with ( & parent_dir) ) {
130
+ if item. rtype == "tree" . to_string ( ) {
131
+ let msg_index = result. insert_data ( msg. clone ( ) ) ;
132
+ result. file . push ( ( item. clone ( ) , msg_index) ) ;
133
+ has. push ( parent_dir. to_string ( ) ) ;
134
+ }
135
+ }
136
+ }
137
+ }
127
138
if let Some ( path) = path. to_str ( ) . map ( |x| x. to_string ( ) ) {
128
139
if has. contains ( & path) {
129
140
continue ;
130
141
}
131
142
if let Some ( item) = state_tree. iter ( ) . find ( |x| x. to_path ( ) == path) {
132
- let msg_index = result. insert_data ( msg. clone ( ) ) ;
133
- result. file . push ( ( item. clone ( ) , msg_index) ) ;
134
- has. push ( item. to_path ( ) ) ;
143
+ if item. rtype == "blob" . to_string ( ) {
144
+ let msg_index = result. insert_data ( msg. clone ( ) ) ;
145
+ result. file . push ( ( item. clone ( ) , msg_index) ) ;
146
+ has. push ( item. to_path ( ) ) ;
147
+ }
135
148
}
136
149
}
137
150
}
138
151
}
152
+ if has. len ( ) == state_tree. len ( ) {
153
+ break ;
154
+ }
139
155
commit = parent;
140
156
}
141
157
Ok ( result)
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ interface FileApiResponse {
46
46
}
47
47
48
48
export const RepoFiles = ( ) => {
49
- const { owner, repo, path } = useParams < { owner : string ; repo : string ; path ?: string } > ( ) ;
49
+ const { owner, repo, '*' : path } = useParams ( ) ;
50
50
const navigate = useNavigate ( ) ;
51
51
const [ loading , setLoading ] = useState ( true ) ;
52
52
const [ error , setError ] = useState < string | null > ( null ) ;
@@ -112,14 +112,26 @@ export const RepoFiles = () => {
112
112
{ files . length ? (
113
113
< div className = "h-[calc(100vh-250px)] overflow-auto" >
114
114
< div >
115
+ {
116
+ path != "" && path && (
117
+ < div >
118
+ < div className = "flex items-center" onClick = { ( ) => {
119
+ navigate ( `/${ owner } /${ repo } /tree/${ path . split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) } ` ) ;
120
+ } } >
121
+ < GitBranch size = { 18 } className = "mr-2 text-blue-500" />
122
+ < div > ...</ div >
123
+ </ div >
124
+ </ div >
125
+ )
126
+ }
115
127
{ files . map ( ( [ file , idx ] , index ) => (
116
128
< div
117
129
key = { index }
118
130
className = { `cursor-pointer ${ index === files . length - 1 ? '' : 'border-b border-gray-200' } flex items-center justify-between` }
119
131
onClick = { ( ) => {
120
132
if ( file . rtype === 'tree' ) {
121
133
const newPath = path ? `${ path } /${ file . name } ` : file . name ;
122
- navigate ( `/repo/ ${ owner } /${ repo } /tree/${ newPath } ` ) ;
134
+ navigate ( `/${ owner } /${ repo } /tree/${ newPath } ` ) ;
123
135
}
124
136
} }
125
137
>
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export default function AppRoutes() {
62
62
element : < RepoCommit />
63
63
} ,
64
64
{
65
- path : 'tree/:path *' ,
65
+ path : 'tree/*' ,
66
66
element : < RepoFiles />
67
67
}
68
68
]
You can’t perform that action at this time.
0 commit comments