Skip to content

Commit

Permalink
using git remote -v to get the identifier for first remote listed on …
Browse files Browse the repository at this point in the history
…repo (#473)

* using git remote -v to get the identifier for first remote listed on repo

* adding thing

* updating version
  • Loading branch information
mmclead authored Nov 27, 2023
1 parent f11f109 commit 0b9666d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swdc-vscode",
"displayName": "Code Time",
"version": "2.7.4",
"version": "2.7.5",
"publisher": "softwaredotcom",
"description": "Code Time is an open source plugin that provides programming metrics right in Visual Studio Code.",
"author": {
Expand Down Expand Up @@ -151,4 +151,4 @@
"uuid": "^9.0.1",
"ws": "^8.14.2"
}
}
}
4 changes: 2 additions & 2 deletions src/managers/ExecManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logIt } from '../Util';

const {execSync} = require('child_process');
const { execSync } = require('child_process');

export function execCmd(cmd: string = '', projectDir: string | null = null, returnLines: boolean = false): any {
let result = returnLines ? [] : null;
Expand All @@ -10,7 +10,7 @@ export function execCmd(cmd: string = '', projectDir: string | null = null, retu
}

try {
const opts = projectDir ? {cwd: projectDir, encoding: 'utf8'} : {encoding: 'utf8'};
const opts = projectDir ? { cwd: projectDir, encoding: 'utf8' } : { encoding: 'utf8' };

const cmdResult = execSync(cmd, opts);
if (cmdResult && cmdResult.length) {
Expand Down
12 changes: 7 additions & 5 deletions src/repo/KpmRepoManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {isGitProject} from '../Util';
import {CacheManager} from '../cache/CacheManager';
import {execCmd} from '../managers/ExecManager';
import { isGitProject } from '../Util';
import { CacheManager } from '../cache/CacheManager';
import { execCmd } from '../managers/ExecManager';

const cacheMgr: CacheManager = CacheManager.getInstance();
const cacheTimeoutSeconds = 60 * 15;
Expand All @@ -25,13 +25,15 @@ export async function getResourceInfo(projectDir: string) {
resourceInfo = {};

const branch = execCmd('git symbolic-ref --short HEAD', projectDir);
const identifier = execCmd('git config --get remote.origin.url', 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];
let email = execCmd('git config user.email', projectDir);
const tag = execCmd('git describe --all', projectDir);

// both should be valid to return the resource info
if (branch && identifier) {
resourceInfo = {branch, identifier, email, tag};
resourceInfo = { branch, identifier, email, tag };
cacheMgr.set(cacheId, resourceInfo, cacheTimeoutSeconds);
}
return resourceInfo;
Expand Down
Binary file modified swdc-vscode-2.7.4.vsix
Binary file not shown.

0 comments on commit 0b9666d

Please sign in to comment.