-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffNpatch.js
More file actions
75 lines (58 loc) · 2.36 KB
/
Copy pathdiffNpatch.js
File metadata and controls
75 lines (58 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var components = require('ungit-components');
var ko = require('knockout');
var inherits = require('util').inherits;
var GraphActions = components.create('git-graph-actions');
GraphActions.DiffNpatch = function(graph, node) {
var self = this;
GraphActions.ActionBase.call(this, graph);
this.node = node;
this.visible = ko.computed(function() {
if (self.performProgressBar.running()) return true;
return self.graph.currentActionContext() == self.node
});
}
inherits(GraphActions.DiffNpatch, GraphActions.ActionBase);
GraphActions.DiffNpatch.prototype.text = 'Diff & patch';
GraphActions.DiffNpatch.prototype.style = 'DiffNpatch';
GraphActions.DiffNpatch.prototype.icon = 'octicon octicon-file-symlink-directory';
GraphActions.DiffNpatch.prototype.perform = function(callback) {
var self = this;
var server = this.server;
var current_repoPath = this.graph.repoPath();
var parent_sha1 = this.node.sha1;
if(typeof this.node.belowNode != 'undefined'){
parent_sha1 = this.node.belowNode.sha1;
}
var patch_name = prompt("Patch name?");
if(patch_name != null && patch_name.trim() != ''){
// this.server.postPromise('/revert', { path: this.graph.repoPath(), commit: this.node.sha1 })
// .finally(callback);
server.get('/plugins/diffNpatch/pack', { path: current_repoPath ,pid: parent_sha1,patch_name:patch_name}, function(err, hook) {
// console.log(err, hook);
callback();
});
} else {
alert("Patch name is empty?");
callback();
}
}
var graphConstructor = components.registered['graph'];
components.register('graph', function(args) {
var graph = graphConstructor(args);
// var graphUpdateNode = graph.updateNode.bind(graph);
graph.getNode = function(sha1, logEntry) {
var self = this;
// var nodeViewModel = self.getNodeOrg(sha1);
// nodeViewModel.dropareaGraphActions.push(new GraphActions.DiffNpatch(graph, self));
var nodeViewModel = this.nodesById[sha1];
if (!nodeViewModel) {
var gitnodeviewmodel = components.create("git-node", {"graph":graph,"sha1":sha1});
gitnodeviewmodel.dropareaGraphActions.push(new GraphActions.DiffNpatch(graph, gitnodeviewmodel));
// gitnodeviewmodel.dropareaGraphActions = [(new GraphActions.Revert(graph, this))];
nodeViewModel = this.nodesById[sha1] = gitnodeviewmodel;
}
if (logEntry) nodeViewModel.setData(logEntry);
return nodeViewModel;
}
return graph;
});