Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/git-log-class.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ class ColumnView extends View
@p =>
@span content
###

43 changes: 33 additions & 10 deletions lib/git-log-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var GitLogView = require("./git-log-class");
var BufferedProcess = require("atom").BufferedProcess;
var LogParser = require("./logparser");
var GitGraph = require("./gitgraph");
var $ = require("atom").$;
var $ = require("atom-space-pen-views").$;

var __bind = function(fn, me) {
return function() {
Expand All @@ -14,14 +14,14 @@ var safe_tags = function(str) {
return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') ;
};

GitLogView.prototype.initialize = function(repo_name) {
GitLogView.prototype.initialize = function(repo) {
var editorFontSize = atom.config.get('editor.fontSize');
var editorLineHeight = atom.config.get('editor.lineHeight');
var fontScale = atom.config.get('git-log.fontScale');
this.font_family = atom.config.get('git-log.fontFamily');

this.repo = repo;
this.info_panel.hide();
this.path = repo_name;
this.path = repo.repo_name;

this.font_size = editorFontSize * fontScale;
this.line_height = Math.round(this.font_size * editorLineHeight);
Expand Down Expand Up @@ -53,7 +53,8 @@ GitLogView.prototype.get_log = function() {

var args = ['log', '--decorate=full', '--date=default', '--pretty=fuller', '--all', '--parents', '--numstat', '--topo-order', '--raw'];
var options = {};
options.cwd = atom.project.getRepo().getWorkingDirectory();
options.cwd = this.repo.getWorkingDirectory();

return new BufferedProcess({
command: 'git',
args: args,
Expand All @@ -77,13 +78,19 @@ GitLogView.prototype.log_callback = function(data) {
};
})(this));
**/
this.on('core:cancel core:close', (function(self) {
atom.commands.add('.git-log', 'core:cancel', (function(self) {
return function(e) {
self.info_panel.hide();
};
})(this));

atom.commands.add('.git-log', 'core:close', (function(self) {
return function(e) {
self.info_panel.hide();
};
})(this));

this.on('core:move-up', (function(self) {
atom.commands.add('.git-log', 'core:move-up', (function(self) {
return function(e) {
if((self.previous_line == null) || (self.previous_line == 1))
return;
Expand All @@ -94,7 +101,7 @@ GitLogView.prototype.log_callback = function(data) {
};
})(this));

this.on('core:move-down', (function(self) {
atom.commands.add('.git-log', 'core:move-down', (function(self) {
return function(e) {
if((self.previous_line == null) || (self.previous_line == self.log.length))
return;
Expand All @@ -114,7 +121,15 @@ GitLogView.prototype.parser = function() {
GitLogView.prototype.fill_content = function() {
var create_main_row = function(log) {
var html = '<tr><td><p> &nbsp;</p></td>';
html += '<td><p>' + log.message.split('\n')[0] + '</p></td>';
html += '<td><p>';
if (log.refs.length > 0) {
html += '<span class="label">';
html += log.refs.map(function(str) {
return str.replace(/^.*\/(remotes|heads)\//,'');
}).join('</span><span class="label">');
html += '</span>'
}
html += log.message.split('\n')[0] + '</p></td>';
html += '<td><p>' + log.sha1.slice(0, 7)+ '</p></td>';

var date = log.author_date.split(/ /);
Expand Down Expand Up @@ -169,10 +184,18 @@ GitLogView.prototype.getTitle = function() {
return "Git-log: " + this.path;
};

GitLogView.prototype.getUri = function() {
GitLogView.prototype.getURI = function() {
return "git-log://" + this.path;
};

GitLogView.prototype.onDidChangeTitle = function() {
return;
};

GitLogView.prototype.onDidChangeModified = function() {
return;
};

GitLogView.prototype.get_image = function(email) {
var crypto = require('crypto');
var base = "http://www.gravatar.com/avatar/";
Expand Down
44 changes: 21 additions & 23 deletions lib/git-log.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var url = require('url');
var path = require('path');

module.exports = {
config: {
Expand All @@ -16,18 +15,28 @@ module.exports = {
},
activate: function() {
atom.commands.add("atom-workspace", "git-log:show", function(event) {
var path;
if((path = check_repo_validity()) !== null) {
var uri = "git-log://" + path;
var old_pane = atom.workspace.paneForUri(uri);
if (old_pane) {
old_pane.destroyItem(old_pane.itemForUri(uri));
/** Check valid repository */
var repository = Promise.all(atom.project.getDirectories().map(
atom.project.repositoryForDirectory.bind(atom.project)));
repository.then(function(repos) {
if(repos.length > 0) {
var repo_list = [];
var name;

for(var i=0; i<repos.length; i++) {
if(repos[i] == null)
continue;
repos[i].repo_name = repos[i].getWorkingDirectory().match(/([^\/]*)\/*$/)[1];
repo_list.push(repos[i]);
}
var RepoView = require('./git-repo-list.coffee');

new RepoView(repo_list);
}
atom.workspace.open(uri);
}
})
});
});

return atom.workspace.addOpener(function(uri) {
return atom.workspace.addOpener(function(uri, options) {
var error, host, pathname, protocol, ref;
try {
ref = url.parse(uri);
Expand All @@ -44,18 +53,7 @@ module.exports = {
return;
}
var GitLogView = require('./git-log-view');
return new GitLogView(host);
return new GitLogView(options.repo);
});
}
};

var check_repo_validity = function() {
var repository = atom.project.getRepo();
if(repository !== null) {
var repo_path = repository.getWorkingDirectory();
return path.basename(repo_path);
}
else {
return null;
}
}
34 changes: 34 additions & 0 deletions lib/git-repo-list.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{$$, SelectListView} = require 'atom-space-pen-views'


module.exports =

class RepoListView extends SelectListView
initialize: (@listOfItems) ->
super
@addClass('modal overlay from-top')
@storeFocusedElement()
@panel = atom.workspace.addModalPanel(item: this, visible: true)
@panel.show()
@setItems(@listOfItems)
@focusFilterEditor()

getFilterKey: ->
'repo_name'

viewForItem: (item) ->
$$ -> @li(item.repo_name)

cancelled: ->
@panel.hide()
@panel.destroy()

confirmed: (item) ->
@cancel()
options= {
'repo': item
};
uri = "git-log://" + item.repo_name
old_pane = atom.workspace.paneForURI(uri)
old_pane.destroyItem old_pane.itemForURI(uri) if old_pane
atom.workspace.open uri, options
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "git-log",
"main": "./lib/git-log.js",
"version": "0.3.0",
"version": "0.4.1",
"description": "This package graphs your git commits",
"repository": "https://github.com/nikhilkalige/git-log",
"license": "MIT",
Expand Down
13 changes: 13 additions & 0 deletions styles/git-log.less
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@
text-align: left;
margin: 0 -@margin;
}

.label {
position: relative;
vertical-align: text-bottom;
font-size: inherit;
display: inline-block;
border: 2px solid @syntax-color-constant;
box-sizing:border-box;
padding: 1px;
background-color: @syntax-selection-flash-color;
color: @syntax-background-color;
margin-right: 4px;
}
}

.info {
Expand Down