Skip to content

Commit 56a5e29

Browse files
committed
Add #42 show current directory name as a project name
1 parent ed274f1 commit 56a5e29

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

controller/main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var editor = require('./editor'),
1111
var config = require('../config');
1212

1313
// model control
14-
var git = new Git(__dirname);
14+
var git = new Git(process.cwd());
1515

1616
// for convenience.
1717
// use just call redraw() anywhere if need screen.render()
@@ -98,11 +98,19 @@ var main = {
9898
}
9999
},
100100

101+
setBranchLine: function () {
102+
var branchLine =
103+
"{blue-fg}" + git.getCurrentProjectName() + ":{/blue-fg}" +
104+
"{yellow-fg}" + git.getCurrentBranchName() + "{/yellow-fg}";
105+
106+
view.branchbox.setContent(branchLine);
107+
},
108+
101109
// initialize
102110
reload: function () {
103111
git.status();
104112

105-
view.branchbox.setText(git.getCurrentBranchName());
113+
main.setBranchLine();
106114

107115
main.setItems();
108116

model/git.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
var _ = require('lodash'),
2+
path = require('path'),
23
execSync = require('child_process').execSync;
34

45
// TODO: get git command from shell
56
var gitExec = 'git';
67

7-
function Git (path) {
8-
this.path = path;
8+
function Git (repoPath) {
9+
this.repoPath = repoPath;
10+
11+
this.projectName = repoPath.split(path.sep).pop();
912

1013
this.loadBranches();
1114
}
@@ -27,15 +30,15 @@ Git.prototype.clear = function () {
2730
};
2831
};
2932

30-
Git.prototype.setStatus = function (code, path) {
33+
Git.prototype.setStatus = function (code, filePath) {
3134
if (code.charAt(0) !== '?' && code.charAt(0) !== ' ') {
32-
this.files.staged.push(path);
35+
this.files.staged.push(filePath);
3336
this.selected.staged.push(false);
3437
this.symbols.staged.push(code.charAt(0));
3538
}
3639

3740
if (code.charAt(1) !== ' ') {
38-
this.files.unstaged.push(path);
41+
this.files.unstaged.push(filePath);
3942
this.selected.unstaged.push(false);
4043
this.symbols.unstaged.push(code.charAt(1));
4144
}
@@ -235,6 +238,10 @@ Git.prototype.getCurrentBranchName = function () {
235238
return this.branches[this.currentBranchIndex];
236239
};
237240

241+
Git.prototype.getCurrentProjectName = function () {
242+
return this.projectName;
243+
};
244+
238245
Git.prototype.checkout = function (branchIndex) {
239246
var gitCommand = gitExec + ' checkout ' + this.branches[branchIndex];
240247

view/style/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,9 @@ module.exports = function (config) {
8585
"height": 1,
8686
"width": "100%",
8787
"align": "right",
88+
"tags": true,
8889
"padding": {
8990
"right": 2
90-
},
91-
"style": {
92-
"fg": "yellow"
9391
}
9492
},
9593
"menubar1": {

0 commit comments

Comments
 (0)