Skip to content

Commit

Permalink
fix: get rootUri from VSCodeGit.Repository (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-Xu-0100 authored Dec 30, 2022
1 parent a6fe858 commit cbdcfd2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ function getGitAPI(): VSCodeGit.API {
return vscodeGit!.exports.getAPI(1);
}

type Arg = {
_rootUri?: vscode.Uri;
};

function hasChanges(repo: VSCodeGit.Repository) {
return (
repo.state.workingTreeChanges.length ||
Expand All @@ -41,11 +37,11 @@ async function getRepository({
workspaceFolders,
}: {
git: VSCodeGit.API;
arg?: Arg;
arg?: vscode.Uri;
workspaceFolders?: readonly vscode.WorkspaceFolder[];
}) {
const _arg = arg?._rootUri?.fsPath;
output.info(`arg: ${_arg}`);
const _arg = arg?.fsPath;
output.info(`_arg: ${_arg}`);

const repositories = git.repositories
.map((repo) => repo.rootUri.fsPath)
Expand Down Expand Up @@ -105,7 +101,7 @@ async function getRepository({
}

export default function createConventionalCommits() {
return async function conventionalCommits(arg?: Arg) {
return async function conventionalCommits(repoUri?: VSCodeGit.Repository | vscode.Uri) {
try {
output.info('Conventional commits started.');

Expand All @@ -124,8 +120,12 @@ export default function createConventionalCommits() {
const git = getGitAPI();

// 3. get repository
let _repoUri = repoUri;
if (!(repoUri instanceof vscode.Uri) && (repoUri !== undefined)) {
_repoUri = repoUri.rootUri;
}
const repository = await getRepository({
arg,
arg: (<vscode.Uri | undefined>_repoUri),
git: git,
workspaceFolders: vscode.workspace.workspaceFolders,
});
Expand Down

0 comments on commit cbdcfd2

Please sign in to comment.