summaryrefslogtreecommitdiff
blob: d28897b6e8ffad2bb41ee57e7956daf3c63c9b8a (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/ruby -w

$: << File.dirname(__FILE__)

module ChangeLog
    def ChangeLog.getLastEntry()
	    f = File.new('ChangeLog')
    	entry=''

       	while line = f.gets
            # TODO parametize this
            if(line.match(/nichoj@gentoo.org/))
                while ! line.match(/:$/)
                    line = f.gets
                end

                while (line = f.gets) && line.strip != ''
                    entry += line.strip + ' '
                end
                break
            end
        end

    	f.close
        return entry.rstrip
    end
end

def isSvn
    File.directory? '.svn'
end

def isCvs
	File.directory? 'CVS'
end

def display_heading(message)
    max = 80
    filler = '#######################'
    remaining = max - filler.length * 2
    leader = (remaining - message.length ) / 2
    puts filler + ' ' * (leader) + message + ' ' * leader + filler
end

def hr
    max = 80
    puts '#' * max
end


def show_keywords()
	display_heading('Keywords')
	system('adjutrix --keyword-graph 2>/dev/null')
end

def show_diff()
	if isSvn or isCvs
		display_heading('diff')
		if isSvn
		    system('svn diff')
		elsif isCvs
		    system('cvs diff')
		end
		puts 'Exit status: ' + $?.to_s
		return $?
	end
end

def show_repoman
	display_heading 'repoman full'
	system('repoman full')
	puts 'Exit status: ' + $?.to_s
	return $?
end

def show_qualudis
	display_heading 'qualudis'
	system('qualudis')
	puts 'Exit status: ' + $?.to_s
	return $?
end

def get_logentry()
# use log entry from command line
	logentry = ARGV[0]
	# or default to your last ChangeLog entry
	if logentry.nil? and File.file?('ChangeLog')
	    logentry = ChangeLog.getLastEntry()
	end
	return logentry
end

def show_logentry(logentry)
	display_heading('ChangeLog')
	puts logentry
	display_heading('Continue? (yes/no)')
end

show_keywords
show_diff or exit 1
show_qualudis or exit 1
show_repoman or exit 1


logentry = get_logentry()

# escape the log entry
escaped = logentry.gsub("'") { "\\'" }

show_logentry(logentry)


line = gets
if line.match(/y|yes/i)
    display_heading('Committing...')
    if isSvn
        system("svn commit -m \"#{escaped}\"")
    else
        system("repoman commit -m \"#{escaped}\"")
    end
end