Skip to content

Commit

Permalink
Git remote checking -- choose origin first (#474)
Browse files Browse the repository at this point in the history
* finding origin if it exists, otherwise take first remote we see

* correcting comments
  • Loading branch information
mmclead authored Nov 27, 2023
1 parent 0b9666d commit 842bf53
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/repo/KpmRepoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ export async function getResourceInfo(projectDir: string) {
resourceInfo = {};

const branch = execCmd('git symbolic-ref --short HEAD', projectDir);
const first_remote = execCmd('git remote -v', projectDir);
// returns something like: origin\thttps://github.com/swdotcom/swdc-vscode.git (fetch)'
const identifier = first_remote.split('\t')[1].split(' ')[0];
// returns something like: ['origin\thttps://github.com/swdotcom/swdc-vscode.git (fetch)', 'origin\thttps://github.com/swdotcom/swdc-vscode.git (push)']
const remotes = execCmd('git remote -v', projectDir, true);
// find a line that starts with 'origin'
const origin_remote = remotes.find((line: string) => line.startsWith('origin\t'));
const remote_name = origin_remote ? 'origin' : remotes[0].split('\t')[0];

const identifier = execCmd(`git remote get-url ${remote_name}`, projectDir);
let email = execCmd('git config user.email', projectDir);
const tag = execCmd('git describe --all', projectDir);

Expand Down

0 comments on commit 842bf53

Please sign in to comment.