Skip to content

Commit

Permalink
Integrate with latest version of grit. Load gmCommands from applicati…
Browse files Browse the repository at this point in the history
…on support directory.
  • Loading branch information
Justin Palmer committed Aug 30, 2008
1 parent 864414b commit 2c76c3c
Show file tree
Hide file tree
Showing 22 changed files with 3,272 additions and 26 deletions.
8 changes: 8 additions & 0 deletions GitNub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
283254680D8B792500D99366 /* lib in Resources */ = {isa = PBXBuildFile; fileRef = 283254650D8B792500D99366 /* lib */; };
288853050D7CE2E500862D67 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 288853040D7CE2E500862D67 /* LICENSE */; };
288CB41A0D8789DD0092B5CC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 288CB4180D8789DD0092B5CC /* MainMenu.xib */; };
28DAB0220E672FF1004DB17C /* PluginForm.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28DAB0210E672FF1004DB17C /* PluginForm.xib */; };
28DAB03F0E676094004DB17C /* boot.rb in Resources */ = {isa = PBXBuildFile; fileRef = 28DAB03E0E676094004DB17C /* boot.rb */; };
4DDCA7070ACC9A6100E082CE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
4DDCA7080ACC9A6100E082CE /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = E8F5E25803AEB7C803A81C6F /* rb_main.rb */; };
4DDCA70A0ACC9A6100E082CE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
Expand Down Expand Up @@ -76,6 +78,8 @@
283254650D8B792500D99366 /* lib */ = {isa = PBXFileReference; lastKnownFileType = folder; path = lib; sourceTree = "<group>"; };
288853040D7CE2E500862D67 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
288CB4190D8789DD0092B5CC /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
28DAB0210E672FF1004DB17C /* PluginForm.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PluginForm.xib; sourceTree = "<group>"; };
28DAB03E0E676094004DB17C /* boot.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = boot.rb; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
Expand Down Expand Up @@ -188,6 +192,7 @@
4DDCA7110ACC9A6100E082CE /* Info.plist */,
288853040D7CE2E500862D67 /* LICENSE */,
288CB4180D8789DD0092B5CC /* MainMenu.xib */,
28DAB0210E672FF1004DB17C /* PluginForm.xib */,
);
name = GitNub;
sourceTree = "<group>";
Expand All @@ -198,6 +203,7 @@
283254650D8B792500D99366 /* lib */,
29B97316FDCFA39411CA2CEA /* main.m */,
E8F5E25803AEB7C803A81C6F /* rb_main.rb */,
28DAB03E0E676094004DB17C /* boot.rb */,
);
name = "Other Sources";
sourceTree = "<group>";
Expand Down Expand Up @@ -297,6 +303,8 @@
281AEACC0E65418500B48530 /* ImageLoadOperation.rb in Resources */,
281AEACE0E6541AB00B48530 /* Info.xib in Resources */,
281AED6C0E6677B500B48530 /* GitNubWebView.rb in Resources */,
28DAB0220E672FF1004DB17C /* PluginForm.xib in Resources */,
28DAB03F0E676094004DB17C /* boot.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
30 changes: 30 additions & 0 deletions boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$VERBOSE = nil
require 'rubygems'
require 'pathname'
require 'osx/cocoa'


# Do some mangling to the load order so grit will use our bundled
# items instead of the gem versions.
#
libdir = OSX::NSBundle.mainBundle.resourcePath.stringByAppendingPathComponent("lib").fileSystemRepresentation
$:.unshift(libdir, "#{libdir}/grit/lib", "#{libdir}/mime-types/lib", "#{libdir}/open4/lib", "#{libdir}/diff-lcs/lib")

require 'grit'

# Require some core extensions
#
require 'time_extensions'
require 'string_extensions'
require 'osx_notify'

# Custom gravatar cell support
#
OSX.ns_import 'CommitSummaryCell'
include OSX

# we use ENV['PWD'] instead of Dir.getwd if it exists so
# `open GitNub` will work, since that launches us at / but leaves ENV['PWD'] intact
#
pwd = Pathname.new(ENV['PWD'].nil? ? Dir.getwd : ENV['PWD'])
REPOSITORY_LOCATION = pwd + `cd #{pwd} && git rev-parse --git-dir 2>/dev/null`.chomp
48 changes: 29 additions & 19 deletions controllers/ApplicationController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,9 @@
# Created by Justin Palmer on 3/1/08.
# Copyright (c) 2008 Active Reload, LLC. All rights reserved.
#
$VERBOSE = nil
require 'rubygems'
require 'pathname'
require 'osx/cocoa'
libdir = OSX::NSBundle.mainBundle.resourcePath.stringByAppendingPathComponent("lib").fileSystemRepresentation
$:.unshift(libdir, "#{libdir}/grit/lib", "#{libdir}/mime-types/lib", "#{libdir}/open4/lib")
require 'grit'
require 'time_extensions'
require 'string_extensions'
require 'osx_notify'
require 'boot'
require 'InfoWindowController'

OSX.ns_import 'CommitSummaryCell'
include OSX

# we use ENV['PWD'] instead of Dir.getwd if it exists so
# `open GitNub` will work, since that launches us at / but leaves ENV['PWD'] intact
pwd = Pathname.new(ENV['PWD'].nil? ? Dir.getwd : ENV['PWD'])
REPOSITORY_LOCATION = pwd + `cd #{pwd} && git rev-parse --git-dir 2>/dev/null`.chomp

class ApplicationController < OSX::NSObject
ib_outlet :commits_table
ib_outlet :commits_controller
Expand Down Expand Up @@ -64,6 +47,7 @@ def awakeFromNib

setup_search_field
setup_refs_view_menu
load_commands

Notify.on "tab_view_changed" do |opts|
if(opts[:tab_item] != "commits")
Expand All @@ -74,7 +58,6 @@ def awakeFromNib
@search_field.setEnabled(true)
end
end

end
end

Expand All @@ -86,6 +69,14 @@ def repo
end
end

def app_name
NSFileManager.defaultManager.displayNameAtPath(main_bundle_path)
end

def main_bundle_path
NSBundle.mainBundle.bundlePath
end

def draggingEntered(sender)
puts sender
end
Expand Down Expand Up @@ -178,4 +169,23 @@ def setup_search_field
add_menu_item.call("Path", "Find commits based on a path", false)
@search_field.cell.setPlaceholderString("Search commits...")
end

def load_commands
file_manager = NSFileManager.defaultManager
search_paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSUserDomainMask, true);

search_paths.each do |path|
support_path = File.join(path, app_name)
unless File.exists?(support_path)
file_manager.createDirectoryAtPath_attributes(support_path, NSFileTypeDirectory)
end

Dir[support_path + "/**/*.gnCommand"].each do |f|
puts Pathname.new(f).basename
load f
end
end

end
end
2 changes: 1 addition & 1 deletion controllers/CommitsController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def fetch_git_branch
end

def fetch_commits_for(branch, quanity, offset = 0)
@commits = @repo.commits(branch, quanity, offset)
@commits = @repo.commits(branch.to_s, quanity, offset)
end

def setup_paging_control
Expand Down
46 changes: 46 additions & 0 deletions lib/diff-lcs/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Revision history for Ruby library Diff::LCS. Unless explicitly noted otherwise,
all changes are produced by Austin Ziegler <diff-lcs@halostatue.ca>.

== Diff::LCS 1.1.2
* Fixed a problem reported by Mauricio Fernandez in htmldiff. Future versions
of Diff::LCS will be removing this program.

== Diff::LCS 1.1.1
* Fixed bug #891:
http://rubyforge.org/tracker/?func=detail&atid=407&aid=891&group_id=84
* Fixed a problem with callback initialisation code (it assumed that all
callbacks passed as classes can be initialised; now, it rescues
NoMethodError in the event of private :new being called).
* Modified the non-initialisable callbacks to have a private #new method.
* Moved ldiff core code to Diff::LCS::Ldiff (diff/lcs/ldiff.rb).

== Diff::LCS 1.1.0
* Eliminated the need for Diff::LCS::Event and removed it.
* Added a contextual diff callback, Diff::LCS::ContextDiffCallback.
* Implemented patching/unpatching for standard Diff callback output formats
with both #diff and #sdiff.
* Extensive documentation changes.

== Diff::LCS 1.0.4
* Fixed a problem with bin/ldiff output, especially for unified format.
Newlines that should have been present weren't.
* Changed the .tar.gz installer to generate Windows batch files if ones do not
exist already. Removed the existing batch files as they didn't work.

== Diff::LCS 1.0.3
* Fixed a problem with #traverse_sequences where the first difference from the
left sequence might not be appropriately captured.

== Diff::LCS 1.0.2
* Fixed an issue with ldiff not working because actions were changed from
symbols to strings.

== Diff::LCS 1.0.1
* Minor modifications to the gemspec, the README.
* Renamed the diff program to ldiff (as well as the companion batch file) so as
to not collide with the standard diff program.
* Fixed issues with RubyGEMs. Requires RubyGems > 0.6.1 or >= 0.6.1 with the
latest CVS version.

== Diff::LCS 1.0
* Initial release based mostly on Perl's Algorithm::Diff.
6 changes: 6 additions & 0 deletions lib/diff-lcs/Install
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Installing this package is as simple as:

% ruby install.rb

Alternatively, you can use the RubyGem version of Diff::LCS available as
diff-lcs-1.1.2.gem from the usual sources.
76 changes: 76 additions & 0 deletions lib/diff-lcs/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Diff::LCS README
================
Diff::LCS is a port of Algorithm::Diff[1] that uses the McIlroy-Hunt
longest common subsequence (LCS) algorithm to compute intelligent
differences between two sequenced enumerable containers[2]. The
implementation is based on Mario I. Wolczko's[3] Smalltalk version (1.2,
1993)[4] and Ned Konz's[5] Perl version (Algorithm::Diff)[6].

This release is version 1.1.2, fixing an htmldiff bug in 1.1.1. Version 1.1.0
added new features, including the ability to #patch and #unpatch changes as
well as a new contextual diff callback, Diff::LCS::ContextDiffCallbacks, that
should improve the context sensitivity of patching.

Using this module is quite simple. By default, Diff::LCS does not extend
objects with the Diff::LCS interface, but will be called as if it were a
function:

require 'diff/lcs'

seq1 = %w(a b c e h j l m n p)
seq2 = %w(b c d e f j k l m r s t)

lcs = Diff::LCS.LCS(seq1, seq2)
diffs = Diff::LCS.diff(seq1, seq2)
sdiff = Diff::LCS.sdiff(seq1, seq2)
seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj)
bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj)
seq2 == Diff::LCS.patch!(seq1, diffs)
seq1 == Diff::LCS.unpatch!(seq2, diffs)
seq2 == Diff::LCS.patch!(seq1, sdiff)
seq1 == Diff::LCS.unpatch!(seq2, sdiff)

Objects can be extended with Diff::LCS:

seq1.extend(Diff::LCS)
lcs = seq1.lcs(seq2)
diffs = seq1.diff(seq2)
sdiff = seq1.sdiff(seq2)
seq = seq1.traverse_sequences(seq2, callback_obj)
bal = seq1.traverse_balanced(seq2, callback_obj)
seq2 == seq1.patch!(diffs)
seq1 == seq2.unpatch!(diffs)
seq2 == seq1.patch!(sdiff)
seq1 == seq2.unpatch!(sdiff)

By requiring 'diff/lcs/array' or 'diff/lcs/string', Array or String will
be extended for use this way.

Copyright
=========
# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
# adapted from:
# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
# implements McIlroy-Hunt diff algorithm
#
# This program is free software. It may be redistributed and/or modified
# under the terms of the GPL version 2 (or later), the Perl Artistic
# licence, or the Ruby licence.
#
# $Id: README,v 1.7 2004/10/17 20:31:10 austin Exp $

Footnotes
=========
[1] This library is called Diff::LCS because there are multiple
Ruby libraries called Algorithm::Diff maintained by other authors.
[2] By sequenced enumerable, I mean that the order of enumeration is
predictable and consistent for the same set of data. While it is
theoretically possible to generate a diff for unordereded hash, it
will only be meaningful if the enumeration of the hashes is
consistent. In general, this will mean that containers that behave
like String or Array will perform best.
[3] mario@wolczko.com
[4] ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st
[5] perl@bike-nomad.com
[6] http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15/
Loading

0 comments on commit 2c76c3c

Please sign in to comment.