MCPcopy Index your code
hub / github.com/21st-dev/1code / parseNameStatus

Function parseNameStatus

src/main/lib/git/utils/parse-status.ts:154–200  ·  view source on GitHub ↗
(nameStatusOutput: string)

Source from the content-addressed store, hash-verified

152}
153
154export function parseNameStatus(nameStatusOutput: string): ChangedFile[] {
155 const files: ChangedFile[] = [];
156
157 for (const line of nameStatusOutput.trim().split("\n")) {
158 if (!line.trim()) continue;
159
160 // Format: status\tfilepath (or status\toldpath\tnewpath for renames)
161 const parts = line.split("\t");
162 const statusCode = parts[0];
163 if (!statusCode) continue;
164
165 const isRenameOrCopy =
166 statusCode.startsWith("R") || statusCode.startsWith("C");
167 const path = isRenameOrCopy ? parts[2] : parts[1];
168 const oldPath = isRenameOrCopy ? parts[1] : undefined;
169
170 if (!path) continue;
171
172 let status: FileStatus;
173 switch (statusCode[0]) {
174 case "A":
175 status = "added";
176 break;
177 case "D":
178 status = "deleted";
179 break;
180 case "R":
181 status = "renamed";
182 break;
183 case "C":
184 status = "copied";
185 break;
186 default:
187 status = "modified";
188 }
189
190 files.push({
191 path,
192 oldPath,
193 status,
194 additions: 0,
195 deletions: 0,
196 });
197 }
198
199 return files;
200}

Callers 2

createStatusRouterFunction · 0.90
getBranchComparisonFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected