blob: cacb4c94b300e68bf66325cca9c21b195b15dd62 (
plain) (
blame)
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
|
---
title: fossil export to git
author: la-ninpre
tags: fossil git tutorial
---
i was trying to export my website repo to fossil using suggested method from
[fossil website][1]:
```
git fast-export --all | fossil import --git repo.fossil
```
[1]:https://www.fossil-scm.org/home/doc/trunk/www/inout.wiki
but i didn't like that fossil recognizes my email as username and so commit
messages user was `user@example.com` instead of `user`.
<!--more-->
i then read a bit about options of `git fast-export` and found `--anonymize`
flag. but it's results weren't satisfying either.
when i looked on a raw output of `git fast-export`, i noticed that commit author
is specified there as
```
author user <user@example.com>
```
and then it's flashed in my head: why not pipe git export through sed and just
replace the contents of `<>` with username instead of email.
so the final command looks like this:
```
git fast-export --all | \
sed -E 's/^((author)|(committer))[[:blank:]]+([[:graph:]]+)[[:blank:]]+(<[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+>)/\1 \4 <\4>/' | \
fossil import --git repo.fossil
```
and it converts
```
author user <user@example.com>
```
to
```
author user <user>
```
which is odd, but fine for fossil import.
---
update: i tested this on a bigger repo with older history and found that this
regexp was not perfect, i updated it to handle situations like
`user@example.co.uk` and also names that consist of more than one word.
```
git fast-export --all | \
sed -E 's/^((author)|(committer))[[:blank:]]+([[:graph:]]+([[:blank:]]+[[:graph:]]+)*)[[:blank:]]+(<[[:graph:]]+@[[:graph:]]+(\.[[:graph:]]+)+>)/\1 \4<\4>/' | \
fossil import --git repo.fossil
```
it's veery evil looking horrible thing, but it works.
|