feature: Commit Log Viewer (#7)

* style: slightly decrease font / button size for repo container

* feat: view commit modal to view local commit details

* fix: allow staging and comitting deleted files

* feat: handle modify-delete edge case
- local side deleted, remote modified
- let user pick between restore, keep deleted
- special handling for editing

* feat: handle empty state for commits modal
This commit is contained in:
Sam Chau
2024-11-19 02:02:48 +10:30
committed by Sam Chau
parent ca84a1c95b
commit 529072dc6c
13 changed files with 1172 additions and 237 deletions

View File

@@ -479,3 +479,32 @@ export const abortMerge = async () => {
throw error;
}
};
export const getCommitHistory = async (branch = null) => {
try {
const url = new URL(`${API_BASE_URL}/git/commits`);
if (branch) {
url.searchParams.append('branch', branch);
}
const response = await axios.get(url.toString(), {
validateStatus: status => {
return (status >= 200 && status < 300) || status === 400;
}
});
return response.data;
} catch (error) {
console.error('Error fetching commit history:', error);
if (error.response?.data) {
return {
success: false,
error: error.response.data.error
};
}
return {
success: false,
error: 'Failed to fetch commit history'
};
}
};