Skip to content

Commit 27faa4f

Browse files
authored
Merge pull request #1 from sourcegraph/workspace-dir
Use environmentDir instead of workspaceDir
2 parents 920af7b + e470c42 commit 27faa4f

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

sourcegraph/c9build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sourcegraph",
33
"description": "Sourcegraph for C9",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"author": "Sourcegraph",
66
"contributors": [
77
{

sourcegraph/c9build/package.sourcegraph.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
define("plugins/sourcegraph/package.sourcegraph", [], {
22
"name": "sourcegraph",
33
"description": "Sourcegraph for C9",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"author": "Sourcegraph",
66
"contributors": [
77
{
@@ -48,8 +48,10 @@ define("plugins/sourcegraph/sourcegraph",[], function(require, exports, module)
4848
var settings = imports.settings
4949
var prefs = imports.preferences
5050
var proc = imports.proc
51+
var environmentDir = imports.c9.environmentDir
5152
var workspaceDir = imports.c9.workspaceDir
5253
var tabs = imports.tabManager
54+
var dirname = require('path').dirname
5355
var VERSION = '0.0.1'
5456

5557
var plugin = new Plugin('Ajax.org', main.consumes)
@@ -221,13 +223,17 @@ define("plugins/sourcegraph/sourcegraph",[], function(require, exports, module)
221223
}
222224

223225
function git(args, callback) {
224-
if (typeof args == 'string') args = args.split(/\s+/)
226+
var tab = tabs.focussedTab
227+
var filePath = tab && tab.path
228+
var baseDir = environmentDir || workspaceDir
229+
var dirPath = dirname(baseDir + filePath)
225230

231+
if (typeof args == 'string') args = args.split(/\s+/)
226232
proc.spawn(
227233
'git',
228234
{
229235
args: args,
230-
cwd: workspaceDir
236+
cwd: dirPath
231237
},
232238
function(e, p) {
233239
buffer(p, function(stdout, stderr) {

sourcegraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sourcegraph",
33
"description": "Sourcegraph for C9",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"author": "Sourcegraph",
66
"contributors": [
77
{

sourcegraph/sourcegraph.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ define(function(require, exports, module) {
1717
var settings = imports.settings
1818
var prefs = imports.preferences
1919
var proc = imports.proc
20+
var environmentDir = imports.c9.environmentDir
2021
var workspaceDir = imports.c9.workspaceDir
2122
var tabs = imports.tabManager
23+
var dirname = require('path').dirname
2224
var VERSION = '0.0.1'
2325

2426
/***** Initialization *****/
@@ -196,13 +198,17 @@ define(function(require, exports, module) {
196198
}
197199

198200
function git(args, callback) {
199-
if (typeof args == 'string') args = args.split(/\s+/)
201+
var tab = tabs.focussedTab
202+
var filePath = tab && tab.path
203+
var baseDir = environmentDir || workspaceDir
204+
var dirPath = dirname(baseDir + filePath)
200205

206+
if (typeof args == 'string') args = args.split(/\s+/)
201207
proc.spawn(
202208
'git',
203209
{
204210
args: args,
205-
cwd: workspaceDir
211+
cwd: dirPath
206212
},
207213
function(e, p) {
208214
buffer(p, function(stdout, stderr) {

0 commit comments

Comments
 (0)