Skip to content

Commit f3513e1

Browse files
committed
Coauthors are now pulled from method/class timeStamps
Fixed project file source directory export.
1 parent 7d1f5c9 commit f3513e1

File tree

30 files changed

+159
-77
lines changed

30 files changed

+159
-77
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
accessing
22
allAuthors
3-
^ (self versionsWithPackageNames collect: #second) asSet asArray sorted
3+
allAuthors
4+
ifNil: [ | authorsSet |
5+
authorsSet := Set new.
6+
self versions
7+
do: [ :each | authorsSet addAll: (self authorsInSnapshot: each veryDeepCopy snapshot) ]
8+
displayingProgress: [ :each | 'Loading authors... ' , each info name ].
9+
allAuthors := authorsSet asArray sorted ].
10+
^ allAuthors
Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
accessing
22
authors: aCollection
3-
| allAuthors |
4-
allAuthors := self allAuthors asOrderedCollection.
5-
aCollection asDictionary associations
6-
do: [ :pair |
7-
(pair key isEmpty or: [ (pair value size = 2) not ])
8-
ifTrue: [ self error: 'Invalid format' ].
9-
(allAuthors includes: pair key)
10-
ifTrue: [ allAuthors remove: pair key ] ].
11-
allAuthors
12-
ifNotEmpty: [ NotFound new
13-
messageText:
14-
'Not all authors have their email set, this is mandatory: '
15-
, (allAuthors joinUsing: ', ');
16-
object: self;
17-
signal ].
183
authors := aCollection asDictionary
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
accessing
2+
authorsInSnapshot: aSnapshot
3+
| timeStamps |
4+
timeStamps := OrderedCollection new.
5+
aSnapshot definitions
6+
do: [ :each |
7+
each isMethodDefinition
8+
ifTrue: [ timeStamps add: each timeStamp ].
9+
(each isClassDefinition and: [ (each isKindOf: MCClassTraitDefinition) not ])
10+
ifTrue: [ timeStamps add: each commentStamp ] ].
11+
^ (timeStamps collect: [ :each | each copyUpTo: Character space ]) \ #('' '<historical>')

repository/GitMigration.package/GitMigration.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"cachedVersions",
1212
"completeAncestryCache",
1313
"versionsWithPackageNames",
14-
"versionsCache"
14+
"versionsCache",
15+
"allAuthors"
1516
],
1617
"name" : "GitMigration",
1718
"type" : "normal"

repository/GitMigration.package/GitMigrationCommitInfo.class/class/info.mapping.committer..st

Lines changed: 0 additions & 6 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
instance creation
2+
info: aVersionInfo mapping: aMapping committer: aCommitter coauthors: aCoauthorsList
3+
^ self new
4+
info: aVersionInfo;
5+
author: (aMapping at: aVersionInfo author);
6+
coauthors:
7+
(aCoauthorsList \ {aVersionInfo author}
8+
collect: [ :each | aMapping at: each ]);
9+
committer: aCommitter
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessing
2+
coauthors: aCollection
3+
coauthors := aCollection
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessing
2+
coauthors
3+
^ coauthors \ {author}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
accessing
22
commitMessage
3-
^ info message " , ' (' , info versionNumber asString , ') ['
4-
, ((info ancestors collect: #versionNumber) joinUsing: ', ') , ']'"
3+
^ String
4+
<< [ :stream |
5+
stream << info message withUnixLineEndings.
6+
(self coauthors sorted: #name ascending)
7+
ifNotEmpty: [ :co |
8+
stream lf.
9+
stream lf.
10+
co
11+
do: [ :each | stream << 'Co-authored-by: ' << each name << ' <' << each email << '>' ]
12+
separatedBy: [ stream lf ] ] ]

repository/GitMigration.package/GitMigrationCommitInfo.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"author",
1111
"committer",
1212
"parents",
13-
"branch"
13+
"branch",
14+
"coauthors"
1415
],
1516
"name" : "GitMigrationCommitInfo",
1617
"type" : "normal"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
instance creation
22
commitInfoFor: aVersionInfo
3-
^ GitMigrationCommitInfo info: aVersionInfo mapping: authorMapping committer: committer
3+
^ writer commitInfoFor: aVersionInfo

repository/GitMigration.package/GitMigrationCommitInfoTest.class/instance/setUp.st

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ setUp
33
super setUp.
44
self timeLimit: 1 minute.
55
self ensureTestRepoLoaded.
6-
" self ensureGitFileTreeLoaded."
6+
" self ensureGitFileTreeLoaded."
77
self ensureAllCached.
8+
writer := GitMigrationFastImportWriter new.
89
authorMapping := GitMigrationAuthorMapping new
910
shortName: 'ImportBot' name: 'Import Bot' email: '[email protected]';
10-
shortName: 'CommitterBot' name: 'Committer Bot' email: '[email protected]'.
11-
committer := authorMapping at: 'CommitterBot'
11+
shortName: 'CommitterBot' name: 'Committer Bot' email: '[email protected]';
12+
shortName: 'JoDoe' name: 'Jo Doe' email: '';
13+
shortName: 'SamDoe' name: 'Sam Doe' email: '[email protected]'.
14+
committer := authorMapping at: 'CommitterBot'.
15+
writer committerName: 'CommitterBot'.
16+
writer authorMapping: authorMapping
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests - commit transform
2+
testCommitMessage
3+
self
4+
assert: (self commitInfoFor: self versionWithoutParent) commitMessage
5+
equals: 'Initial MC commit'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests - commit transform
2+
testCommitMessageWithCoauthors
3+
self
4+
assert: (self commitInfoFor: self versionWithCoauthors) commitMessage
5+
equals:
6+
'Version with coauthors
7+
8+
Co-authored-by: Jo Doe <>
9+
Co-authored-by: Sam Doe <[email protected]>' withUnixLineEndings
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
instance creation
2+
versionWithCoauthors
3+
^ MCVersion
4+
package: (MCPackage named: 'XYZ')
5+
info:
6+
(MCVersionInfo
7+
name: 'FastImported-ImportBot.5'
8+
id: UUID new
9+
message: 'Version with coauthors'
10+
date: (Date year: 2000 month: 12 day: 20)
11+
time: (Time hour: 16 minute: 20 second: 30)
12+
author: 'ImportBot'
13+
ancestors: #())
14+
snapshot:
15+
(MCSnapshot
16+
fromDefinitions:
17+
{MCMethodDefinition
18+
className: 'Something'
19+
selector: #selector
20+
category: #''
21+
timeStamp: 'SamDoe 1/31/2001 01:23'
22+
source: ''.
23+
MCMethodDefinition
24+
className: 'Something'
25+
selector: #otherSelector
26+
category: #''
27+
timeStamp: 'JoDoe 2/31/2001 01:23'
28+
source: ''})
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
instance creation
22
versionWithTwoAncestors
3-
^ MCVersionInfo
4-
name: 'FastImported-ImportBot.3'
5-
id: UUID new
6-
message: 'merge'
7-
date: Date today
8-
time: Time now
9-
author: 'ImportBot'
10-
ancestors:
11-
{self versionWithoutParent.
12-
self versionWithoutParent}
3+
^ MCVersion new
4+
package: (MCPackage named: 'XYZ')
5+
info:
6+
(MCVersionInfo
7+
name: 'FastImported-ImportBot.3'
8+
id: UUID new
9+
message: 'merge'
10+
date: Date today
11+
time: Time now
12+
author: 'ImportBot'
13+
ancestors:
14+
{self versionWithoutParent.
15+
self versionWithoutParent})
16+
snapshot: MCSnapshot empty
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
instance creation
22
versionWithoutParent
3-
^ MCVersionInfo
4-
name: 'FastImported-ImportBot.1'
5-
id: UUID new
6-
message: 'Initial MC commit'
7-
date: (Date year: 2000 month: 12 day: 20)
8-
time: (Time hour: 16 minute: 20 second: 30)
9-
author: 'ImportBot'
10-
ancestors: #()
3+
^ MCVersion
4+
package: (MCPackage named: 'XYZ')
5+
info:
6+
(MCVersionInfo
7+
name: 'FastImported-ImportBot.1'
8+
id: UUID new
9+
message: 'Initial MC commit'
10+
date: (Date year: 2000 month: 12 day: 20)
11+
time: (Time hour: 16 minute: 20 second: 30)
12+
author: 'ImportBot'
13+
ancestors: #())
14+
snapshot: MCSnapshot empty

repository/GitMigration.package/GitMigrationCommitInfoTest.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"classvars" : [ ],
88
"instvars" : [
99
"authorMapping",
10-
"committer"
10+
"committer",
11+
"writer"
1112
],
1213
"name" : "GitMigrationCommitInfoTest",
1314
"type" : "normal"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
accessing
2+
authorsInSnapshot: aSnapshot
3+
| timeStamps |
4+
timeStamps := OrderedCollection new.
5+
aSnapshot definitions
6+
do: [ :each |
7+
each isMethodDefinition
8+
ifTrue: [ timeStamps add: each timeStamp ].
9+
(each isClassDefinition and: [ (each isKindOf: MCClassTraitDefinition) not ])
10+
ifTrue: [ timeStamps add: each commentStamp ] ].
11+
^ (timeStamps collect: [ :each | each copyUpTo: Character space ]) \ #('' '<historical>')
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
converting
2-
commitInfoFor: aVersionInfo
2+
commitInfoFor: aVersion
3+
| snapshotAuthors packageName previousAuthors |
4+
packageName := aVersion package name.
5+
snapshotAuthors := self authorsInSnapshot: aVersion snapshot.
6+
previousAuthors := lastAuthors at: packageName ifAbsent: [ {} ].
7+
lastAuthors at: packageName put: snapshotAuthors.
38
^ GitMigrationCommitInfo
4-
info: aVersionInfo
9+
info: aVersion info
510
mapping: authorMapping
6-
committer: (authorMapping at: committerName)
11+
committer: (authorMapping at: committerName)
12+
coauthors: snapshotAuthors \ previousAuthors

repository/GitMigration.package/GitMigrationFastImportWriter.class/instance/initialize.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ initialize
55
committerName := Author fullName.
66
availableVersions := Dictionary new.
77
exportDirectory := '/'.
8-
fastWriter := GitFastImportFileWriter new
8+
fastWriter := GitFastImportFileWriter new.
9+
lastAuthors := Dictionary new
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
writing
22
writeDeletePackageFor: aVersion
3-
| path |
4-
path := FileSystem unicodeMemory root / exportDirectory / aVersion package name , 'package'.
5-
fastWriter writeDeleteReference: path
3+
self subclassResponsibility
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
writing
22
writeVersion: aVersion
3-
| repository memoryFileOut commitInfo |
4-
commitInfo := self commitInfoFor: aVersion info.
5-
fastWriter writeCommitPreambleFor: commitInfo.
6-
(self commitMarkFor: commitInfo) = 1
7-
ifTrue: [ fastWriter writeLine: 'from ' , initialCommit ].
8-
(memoryFileOut := (FileSystem store: GitFastImportMemoryStore new) root / exportDirectory)
9-
ensureCreateDirectory.
10-
repository := GitMigrationMemoryTreeGitRepository new.
11-
repository directory: memoryFileOut.
12-
repository memoryStoreVersion: aVersion.
13-
self writeDeletePackageFor: aVersion.
14-
fastWriter writeDirectoryTreeInlineFor: memoryFileOut
3+
^ self subclassResponsibility

repository/GitMigration.package/GitMigrationFastImportWriter.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"initialCommit",
1212
"availableVersions",
1313
"exportDirectory",
14-
"fastWriter"
14+
"fastWriter",
15+
"lastAuthors"
1516
],
1617
"name" : "GitMigrationFastImportWriter",
1718
"type" : "normal"

repository/GitMigration.package/GitMigrationFileTreeWriter.class/instance/writeVersion..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
writing
22
writeVersion: aVersion
33
| repository memoryFileOut commitInfo |
4-
commitInfo := self commitInfoFor: aVersion info.
4+
commitInfo := self commitInfoFor: aVersion.
55
fastWriter writeCommitPreambleFor: commitInfo.
66
(self commitMarkFor: commitInfo) = 1
77
ifTrue: [ fastWriter writeLine: 'from ' , initialCommit ].
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
accessing
22
writerClass
3-
^ GitMigrationFastImportWriter
3+
^ GitMigrationFileTreeWriter

repository/GitMigration.package/GitMigrationTest.class/instance/testAllAuthors.st

Lines changed: 0 additions & 3 deletions
This file was deleted.

repository/GitMigration.package/GitMigrationTonelWriter.class/instance/writeProjectFileTo..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ writeProjectFileTo: aDirectory
66
(STONWriter on: stream)
77
prettyPrint: true;
88
newLine: OSPlatform current lineEnding;
9-
nextPut: {'srcDirectory' -> 'repository'} asDictionary ]
9+
nextPut: {'srcDirectory' -> aDirectory basename} asDictionary ]

repository/GitMigration.package/GitMigrationTonelWriter.class/instance/writeVersion..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
writing
22
writeVersion: aVersion
33
| commitInfo memoryStore |
4-
commitInfo := self commitInfoFor: aVersion info.
4+
commitInfo := self commitInfoFor: aVersion.
55
fastWriter writeCommitPreambleFor: commitInfo.
66
(self commitMarkFor: commitInfo) = 1
77
ifTrue: [ fastWriter writeLine: 'from ' , initialCommit ].

repository/GitMigration.package/GitMigrationTonelWriterTest.class/instance/testWriteProject.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ testWriteProject
1313
writer availableVersions: (Array with: v1 info).
1414
writer writeVersion: v1.
1515
self deny: (stream contents lines includes: 'M 100644 inline repository/.project').
16-
self assert: (stream contents lines includes: 'M 100644 inline .project').
16+
self assert: (stream contents lines includes: 'M 100644 inline .project').
17+
self assert: (stream contents lines includes: ' ''srcDirectory'' : ''repository''').

0 commit comments

Comments
 (0)