vcsdiff 0.1.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/vcsdiff +114 -0
- metadata +68 -0
data/bin/vcsdiff
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
# #
|
5
|
+
# File: vcsdiff.rb #
|
6
|
+
# ++++++++++++++++++++++++++++++ #
|
7
|
+
# Copyright (C) 2012 + Author: Foivos S. Zakkak + #
|
8
|
+
# + Website: foivos.zakkak.net + #
|
9
|
+
# + Email: foivos@zakkak.net + #
|
10
|
+
# ++++++++++++++++++++++++++++++ #
|
11
|
+
# #
|
12
|
+
# Based on the script svnvimdiff, written by #
|
13
|
+
# Geoff Buchan <geoffrey.buchan@gmail.com> #
|
14
|
+
# #
|
15
|
+
# This program is free software: you can redistribute it and/or modify #
|
16
|
+
# it under the terms of the GNU General Public License as published by #
|
17
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
18
|
+
# (at your option) any later version. #
|
19
|
+
# #
|
20
|
+
# This program is distributed in the hope that it will be useful, #
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
23
|
+
# GNU General Public License for more details. #
|
24
|
+
# #
|
25
|
+
# You should have received a copy of the GNU General Public License #
|
26
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
27
|
+
# #
|
28
|
+
################################################################################
|
29
|
+
|
30
|
+
require 'optparse'
|
31
|
+
require 'ftools'
|
32
|
+
|
33
|
+
options = {}
|
34
|
+
option_parser = OptionParser.new do |opts|
|
35
|
+
opts.banner = %'Usage: #{opts.program_name} [OPTIONS] -- [DIFF OPTIONS]'
|
36
|
+
opts.separator ''
|
37
|
+
opts.separator 'Options'
|
38
|
+
|
39
|
+
options[:files] = Array.new
|
40
|
+
opts.on('-f','--file FILE',Array,'Define the file/files you want to diff',
|
41
|
+
'(you can use it more than once',
|
42
|
+
'or seperate the filenames with commas)') do |f|
|
43
|
+
options[:files]+=f
|
44
|
+
end
|
45
|
+
|
46
|
+
avail_sys = %w[svn hg git]
|
47
|
+
opts.on('-s','--system NAME',avail_sys,
|
48
|
+
'Define the version control system you are using',
|
49
|
+
"(#{avail_sys.join(',')})",
|
50
|
+
"if not given, #{opts.program_name} tries to automatically detect it"
|
51
|
+
) do |s|
|
52
|
+
options[:sys]=s
|
53
|
+
end
|
54
|
+
|
55
|
+
avail_diff = %w[vimdiff kompare]
|
56
|
+
options[:diff]="vimdiff"
|
57
|
+
opts.on('-t','--tool NAME',avail_diff,
|
58
|
+
'Define the prefered diff visualization tool',
|
59
|
+
"(#{avail_diff.join(',')})",
|
60
|
+
'defaults to vimdiff') do |t|
|
61
|
+
options[:diff]=t
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.separator ''
|
65
|
+
opts.separator 'Diff options:'
|
66
|
+
opts.separator 'All diff options are passed to svn/git/hg diff'
|
67
|
+
opts.separator ''
|
68
|
+
opts.separator 'Common options:'
|
69
|
+
|
70
|
+
opts.on_tail('-h','--help','Show this message') do
|
71
|
+
puts option_parser
|
72
|
+
exit 0;
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
begin
|
77
|
+
option_parser.parse!(ARGV)
|
78
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
79
|
+
puts option_parser
|
80
|
+
exit 1;
|
81
|
+
end
|
82
|
+
|
83
|
+
if options[:sys].length == 0
|
84
|
+
# TODO: implement auto detection
|
85
|
+
options[:sys]="svn"
|
86
|
+
end
|
87
|
+
|
88
|
+
# if the user didn't specify any arguments go through each file in the directory
|
89
|
+
if options[:files].length == 0
|
90
|
+
# FIXME: works only for svn and hg like this
|
91
|
+
modified=%x[#{options[:sys]} status 2> /dev/null | grep -e "^[MU]" | awk '{print $2}']
|
92
|
+
modified.split(%r[\n]).each do |f|
|
93
|
+
options[:files].push(f) if File.file?(f)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
patch="/tmp/svnkomp_747_patch"
|
98
|
+
remote=""
|
99
|
+
|
100
|
+
options[:files].each do |f|
|
101
|
+
remote="/tmp/"+f
|
102
|
+
%x[cp #{f} #{remote}]
|
103
|
+
%x[#{options[:sys]} diff #{ARGV.join(" ")} #{f} > #{patch}]
|
104
|
+
if !($?.success?)
|
105
|
+
exit 1;
|
106
|
+
end
|
107
|
+
%x[patch -R -p0 #{remote} #{patch}]
|
108
|
+
%x[#{options[:diff]} #{remote} #{f}]
|
109
|
+
File.delete(remote)
|
110
|
+
end
|
111
|
+
|
112
|
+
at_exit do
|
113
|
+
%x[rm -rf #{remote} #{patch}]
|
114
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vcsdiff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: -981096060
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- alpha
|
11
|
+
version: 0.1.0.alpha
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Foivos Zakkak
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2012-10-15 00:00:00 Z
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A ruby gem for inspecting diffs generated by git/svn/hg diff using vim or Kompare
|
23
|
+
email: foivos@zakkak.net
|
24
|
+
executables:
|
25
|
+
- vcsdiff
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- bin/vcsdiff
|
32
|
+
homepage: http://rubygems.org/gems/vcsdiff
|
33
|
+
licenses:
|
34
|
+
- GPL-3
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 25
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 3
|
58
|
+
- 1
|
59
|
+
version: 1.3.1
|
60
|
+
requirements:
|
61
|
+
- patch
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.15
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: vcsdiff
|
67
|
+
test_files: []
|
68
|
+
|