krnowak / kgps Goto Github PK
View Code? Open in Web Editor NEWSplitter for git patches
Splitter for git patches
Of course.
Information about file format, clauses, workflows and examples. Probably write a short reason why I wrote this tool.
Basically to have something like:
#ORDER
# SECTION: FOO
# SECTION: BAR
#END_ORDER
#SECTIONS
# SECTION: FOO
# SUBJECT: Foo
# …
# SECTION: BAR
# …
#SECTIONS_END
Happens when previous section clause in the diff is the same as this one.
This needs some warnings code first.
Rather unlikely.
It is awkward to work with.
Follow up from #9:
foo/bar/too/long/a | …
.../too/long/waaaaaaaaay/tooooooo/loooooong | …
foo/bar/too/long/x | …
can be expanded to:
foo/bar/too/long/a | …
foo/bar/too/long/waaaaaaaaay/tooooooo/loooooong | …
foo/bar/too/long/x | …
+
)It's about generating stuff like:
test.sh | 1 +
tests/basic/expected/0001-Add-b.patch | 16 ++++++++++++++++
tests/basic/expected/0002-Add-c.patch | 17 +++++++++++++++++
tests/basic/expected/ADD_B.patch | 5 -----
tests/basic/expected/ADD_C.patch | 6 ------
tests/basic/expected/patches.list | 8 --------
6 files changed, 34 insertions(+), 19 deletions(-)
create mode 100644 tests/basic/expected/0001-Add-b.patch
create mode 100644 tests/basic/expected/0002-Add-c.patch
delete mode 100644 tests/basic/expected/ADD_B.patch
delete mode 100644 tests/basic/expected/ADD_C.patch
delete mode 100644 tests/basic/expected/patches.list
For first iteration I will be happy if 16 ++++++++++++++++
looks like 16 +
.
stat --format='%a %F'
to compare.100
in 100755
means. Maybe it is something to test too.Basically split the thing into smaller functions.
Need a test first.
Currently the generated patches do not overlap.
# OVERLAP
# OUTCOME
c1
c2
c3
+1
+2
a1
a2
a3
# SECTION: FOO
c1
c2
-c3
-a1
a2
a3
# SECTION: BAR
c1
c2
+c3
+1
+2
+a1
a2
a3
# END_OVERLAP
Problems:
Splitter will likely parse the commit message as a patch, instead of ignoring it. I guess I would need to find the first empty line to know where headers end and commit message starts. To find where commit message ends, I would need to find a first empty line starting from the end of the file. That empty line would mean that the listing ends and diffs start. Going back further until a line with ---
would tell me where the commit message ends.
Maybe this can be done without reading the file from the end, but simply to find all empty lines and all lines being ---
. The last empty line is a border between the listing and diffs, and the preceding ---
line would be an end of commit message.
It needs to detect the terminal output, we don't want color when piping things.
Using unicode in subject results in additional headers being generated and subject being escaped.
Not sure if using unicode in commit message or in diffs also causes generation of additional headers.
---
bar => foo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename bar => foo (90%)
diff --git a/bar b/foo
similarity index 90%
rename from bar
rename to foo
index 8e43dd5..bd3d4e8 100644
--- a/bar
+++ b/foo
@@ -2,7 +2,7 @@ aaa
aaa
aaa
aaa
-aaa
+bbb
aaa
aaa
aaa
--
or
---
bar => foo | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename bar => foo (100%)
diff --git a/bar b/foo
similarity index 100%
rename from bar
rename to foo
--
Problem - can't deduce similarity index if we split the changes in the file between sections.
Also would be nice to be able to split the "rename with changes" into either "rename then change" or "change then rename".
Something like # DATE_INC: <dd>:<hh>:<mm>:<ss>
Just take it as a first thing that comes after flags. It's more obvious that way.
To be done after #15.
This is a rather vague issue, but it's here to remind me to think more about how the code should be structured there.
The script collects the commit message from the patch and sections, but it is apparently unused.
This patch produces an error Can't call method "get_sigil" on an undefined value at ../../Kgps/TextDiff.pm line 810, <GEN0> line 55.
From fecc6385233b5dd3acd41ed0bcdc01b61499212b Mon Sep 17 00:00:00 2001
From: Krzesimir Nowak <[email protected]>
Date: Fri, 11 May 2018 22:47:53 +0200
Subject: [PATCH] foo
---
# SECTION: FIRST
# SUBJECT: FIRST
# SECTION: SECOND
# SUBJECT: SECOND
# SECTION: THIRD
# SUBJECT: THIRD
# SECTION: FOURTH
# SUBJECT: FOURTH
a | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/a b/a
index e69de29..d4a8d5c 100644
--- a/a
+++ b/a
@@ -0,0 +1,21 @@
# SECTION: SECOND
+1
+2
+3
# SECTION: FOURTH
+43
+4
+54
+56
# SECTION: FIRST
+456
+
+5768
# SECTION: THIRD
+68
+
# SECTION: FOURTH
+34
+3
+3
# SECTION: FIRST
+
# SECTION: FOURTH
+4
+6
# SECTION: SECOND
+7
# SECTION: THIRD
+87
+
--
2.17.0
Currently I need to specify the current section right after the +++ b/foo
line, otherwise splitter may complain about useless sections. I need to find a reproducer first.
krnowak's git patch splitter - kgps?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.