mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Fix git sync nag showing immediately after cloning external projects
Store the HEAD commit OID as 'shakespeare.clonedAt' git config at clone time, then use it to determine whether the user has actually altered the project before showing the backup warning.
This commit is contained in:
3 files changed
+47
-11
No files matched your search
@@ -39,6 +39,7 @@ interface GitStatus {
|
||||
ahead: number;
|
||||
behind: number;
|
||||
remoteBranchExists: boolean;
|
||||
clonedAtOid: string | null;
|
||||
}
|
||||
|
||||
export function useGitStatus(projectId: string | null) {
|
||||
@@ -61,6 +62,7 @@ export function useGitStatus(projectId: string | null) {
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
remoteBranchExists: false,
|
||||
clonedAtOid: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,6 +85,7 @@ export function useGitStatus(projectId: string | null) {
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
remoteBranchExists: false,
|
||||
clonedAtOid: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -168,6 +171,17 @@ export function useGitStatus(projectId: string | null) {
|
||||
console.warn('Could not get remotes:', error);
|
||||
}
|
||||
|
||||
// Get clonedAt OID (set when project was cloned from an external repo)
|
||||
let clonedAtOid: string | null = null;
|
||||
try {
|
||||
const value = await git.getConfig({ dir: cwd, path: 'shakespeare.clonedAt' });
|
||||
if (typeof value === 'string' && value.length > 0) {
|
||||
clonedAtOid = value;
|
||||
}
|
||||
} catch {
|
||||
// Config key doesn't exist, that's fine
|
||||
}
|
||||
|
||||
// Get git status to see what files have changed
|
||||
const statusMatrix = await git.statusMatrix({
|
||||
dir: cwd,
|
||||
@@ -274,6 +288,7 @@ export function useGitStatus(projectId: string | null) {
|
||||
ahead,
|
||||
behind,
|
||||
remoteBranchExists,
|
||||
clonedAtOid,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error checking git status:', error);
|
||||
@@ -289,6 +304,7 @@ export function useGitStatus(projectId: string | null) {
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
remoteBranchExists: false,
|
||||
clonedAtOid: null,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user