Skip to content

Add a git extensions api to check for unsynced changes #93779

Closed
@wangjaso

Description

@wangjaso

Currently the git extensions api does not have a method to check if the user has unsynced changes. To achieve that I am doing a check like such

    git.onDidOpenRepository(async function(repo: Repository) {
        updateGitChanges(repo.state);

        repo.state.onDidChange(async function(this: any) {
            const repo: any = this;
            updateGitChanges(repo.state);
        }, repo);
    });

async function updateGitChanges(repoState: RepositoryState) {
    const hasChanges = !!(
        repoState.indexChanges.length !== 0 ||
        repoState.mergeChanges.length !== 0 ||
        repoState.workingTreeChanges.length !== 0 ||
        repoState.rebaseCommit !== undefined ||
        (repoState.HEAD?.ahead && repoState.HEAD?.ahead !== 0)
    );

    ...
}

Would be nice to have a api method that does this.
Thanks,
Jason

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitygitGIT issuesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions