Skip to content

Commit fe7aa3e

Browse files
committed
commands should be working, need to test
1 parent 2b076b0 commit fe7aa3e

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

src/commands.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { commands, scm, window } = require("vscode");
22
const { inputCommitMessage, changesCommitted } = require("./messages");
3-
const svn = require("./svn");
3+
const Svn = require("./svn");
44

55
function SvnCommands(model) {
66
this.model = model;
@@ -9,16 +9,23 @@ function SvnCommands(model) {
99
commandId: "svn.commitWithMessage",
1010
method: this.commitWithMessage,
1111
options: { repository: true }
12+
},
13+
{
14+
commandId: "svn.add",
15+
method: this.addFile,
16+
options: {}
17+
},
18+
{
19+
commandId: "svn.fileOpen",
20+
method: this.fileOpen,
21+
options: {}
1222
}
1323
];
1424

1525
this.commands.map(({ commandId, method, options }) => {
1626
const command = this.createCommand(method, options);
1727
commands.registerCommand(commandId, command);
1828
});
19-
// commands.registerCommand("svn.fileOpen", this.fileOpen);
20-
// commands.registerCommand("svn.commitWithMessage", this.commitWithMessage);
21-
// commands.registerCommand("svn.add", this.addFile);
2229
}
2330

2431
SvnCommands.prototype.createCommand = function(method, options) {
@@ -61,25 +68,23 @@ SvnCommands.prototype.fileOpen = resourceUri => {
6168
};
6269

6370
SvnCommands.prototype.commitWithMessage = async function(repository) {
64-
// console.log("fsdsfsf");
65-
// this.svn = new svn();
66-
// let message = await inputCommitMessage(scm.inputBox.value);
71+
const svn = new Svn(repository.root);
72+
let message = repository.inputBox.value;
6773

68-
console.log(repository.inputBox.value);
69-
// try {
70-
// await this.svn.commit(message);
71-
// scm.inputBox.value = "";
72-
// changesCommitted();
73-
// } catch (error) {
74-
// console.log(error);
75-
// }
74+
try {
75+
await this.svn.commit(message);
76+
repository.inputBox.value = "";
77+
changesCommitted();
78+
} catch (error) {
79+
console.log(error);
80+
}
7681
};
7782

7883
SvnCommands.prototype.addFile = async uri => {
7984
this.svn = new svn();
8085

8186
try {
82-
await this.svn.add(uri.resourceUri.path);
87+
await this.svn.add(uri.resourceUri.fsPath);
8388
} catch (error) {
8489
console.log(error);
8590
}

src/repository.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ const Resource = require("./Resource");
33

44
function Repository(repository) {
55
this.repository = repository;
6+
this.root = repository.root;
67
this.watcher = workspace.createFileSystemWatcher("**");
78
this.sourceControl = scm.createSourceControl(
89
"svn",
910
"svn",
10-
Uri.parse(this.repository.root)
11+
Uri.parse(this.root)
1112
);
1213
this.sourceControl.acceptInputCommand = {
1314
command: "svn.commitWithMessage",
@@ -71,11 +72,21 @@ Repository.prototype.update = function() {
7172
case "replaced":
7273
case "missing":
7374
case "added":
74-
changes.push(new Resource(this.repository.root, item.$.path, item["wc-status"].$.item));
75+
changes.push(
76+
new Resource(
77+
this.repository.root,
78+
item.$.path,
79+
item["wc-status"].$.item
80+
)
81+
);
7582
break;
7683
case "unversioned":
7784
notTracked.push(
78-
new Resource(this.repository.root, item.$.path, item["wc-status"].$.item)
85+
new Resource(
86+
this.repository.root,
87+
item.$.path,
88+
item["wc-status"].$.item
89+
)
7990
);
8091
break;
8192
}

src/svn.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
const SvnSpawn = require("svn-spawn");
22
const vscode = require("vscode");
33

4-
function svn() {
4+
function svn(cwd = null) {
55
this.client = new SvnSpawn({
6-
noAuthCache: true
6+
noAuthCache: true,
7+
cwd: cwd
78
});
89
}
910

1011
svn.prototype.getRepositoryRoot = async function(path) {
1112
try {
1213
let result = await this.cmd(["info", path]);
13-
let match = result.match(/(?=Working Copy Root Path:)(.*)/i)[0].replace('Working Copy Root Path:', '').trim();
14+
let match = result
15+
.match(/(?=Working Copy Root Path:)(.*)/i)[0]
16+
.replace("Working Copy Root Path:", "")
17+
.trim();
1418
return match;
1519
} catch (error) {
1620
console.log(error);
@@ -19,7 +23,7 @@ svn.prototype.getRepositoryRoot = async function(path) {
1923

2024
svn.prototype.open = function(repositoryRoot) {
2125
return new Repository(this, repositoryRoot);
22-
}
26+
};
2327

2428
svn.prototype.cmd = function(args) {
2529
return new Promise((resolve, reject) => {
@@ -61,9 +65,8 @@ function Repository(svn, repositoryRoot) {
6165
cwd: this.root,
6266
noAuthCache: true
6367
});
64-
6568
}
6669

6770
Repository.prototype.getStatus = function() {
6871
return this.svn.getStatus();
69-
}
72+
};

0 commit comments

Comments
 (0)