reports/Builder__ChangeReport.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 273 31ab0665a9dc
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Report subclass:#ChangeReport
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:'gofer'
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports-Unfinished'
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!ChangeReport methodsFor:'accessing'!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
changesFor: aResolvedVersion
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
	| references patch |
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	references := gofer allResolved
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
		select: [ :each | each packageName = aResolvedVersion packageName ].
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	patch := MCPatch 
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
		fromBase: (references size > 1 
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
			ifTrue: [ (references at: references size - 1) version snapshot ]
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
			ifFalse: [ MCSnapshot empty ])
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
		target: aResolvedVersion version snapshot.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
	^ patch operations asSortedCollection
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
resolved
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	^ gofer resolved
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
! !
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!ChangeReport methodsFor:'generating'!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
generateChange: aPatch on: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	aPatch isAddition
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
		ifTrue: [ ^ self generateChangeAddition: aPatch on: aStream ].
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
	aPatch isModification
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
		ifTrue: [ ^ self generateChangeModification: aPatch on: aStream ].
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
	aPatch isRemoval
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
		ifTrue: [ ^ self generateChangeRemoval: aPatch on: aStream ]
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
generateChangeAddition: aPatch on: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
	aStream tab; tab; tab; nextPutAll: '<item action="add">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
generateChangeModification: aPatch on: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
	aStream tab; tab; tab; nextPutAll: '<item action="change">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
generateChangeRemoval: aPatch on: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
	aStream tab; tab; tab; nextPutAll: '<item action="remove">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
generateChangeSet: aResolvedVersion on: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
	| info |
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
	info := aResolvedVersion version info.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
	aStream tab; nextPutAll: '<logentry version="'; nextPutAll: (self encode: info name); nextPutAll: '">'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
	aStream tab; tab; nextPutAll: '<date>'; nextPutAll: (self encode: info date yyyymmdd); space; nextPutAll: (self encode: info time print24); nextPutAll: '</date>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
	aStream tab; tab; nextPutAll: '<author>'; nextPutAll: (self encode: info author); nextPutAll: '</author>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
	aStream tab; tab; nextPutAll: '<msg>'; nextPutAll: (self encode: (self convert: info message)); nextPutAll: '</msg>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
	"aStream tab; tab; nextPutAll: '<items>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
	(self changesFor: aResolvedVersion)
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
		do: [ :each | self generateChange: each on: aStream ].
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
	aStream tab; tab; nextPutAll: '</items>'; nextPut: Character lf."
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
	aStream tab; nextPutAll: '</logentry>'; nextPut: Character lf
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
generateOn: aStream
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
	aStream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
	aStream nextPutAll: '<changelog>'; nextPut: Character lf.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
	self resolved
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
		do: [ :each | self generateChangeSet: each on: aStream ].
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
	aStream nextPutAll: '<changelog>'
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
! !
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
!ChangeReport methodsFor:'initialization'!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
initializeOn: aCollection
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
	gofer := Gofer new.
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
	aCollection do: [ :each | gofer package: each ]
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
! !
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
!ChangeReport methodsFor:'running'!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
run
273
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
    86
        | stream |
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
    87
        stream := (Filename defaultDirectory directory / 'changelog.xml') writeStream.
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
    88
        [ self generateOn: stream ]
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
    89
                ensure: [ stream close ]
65
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
! !
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
!ChangeReport class methodsFor:'documentation'!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
version
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
    ^ '$Header$'
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
version_CVS
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    ^ '$Header$'
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
!
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
version_SVN
273
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
   103
    ^ '$Id$'
65
d22c05bd4302 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
! !
273
31ab0665a9dc class: Builder::ChangeReport
Stefan Vogel <sv@exept.de>
parents: 65
diff changeset
   105