Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
valentin_script
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Benozillo
valentin_script
Commits
8f0d06ed
Commit
8f0d06ed
authored
Nov 22, 2024
by
Valentin Benozillo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
squash_commit.py
squash_commit.py
+53
-0
No files found.
squash_commit.py
0 → 100644
View file @
8f0d06ed
file_path
=
'.git/rebase-merge/git-rebase-todo'
original_commit_list
=
[]
fixup_commit_list
=
[]
verification_list
=
[]
original_to_fixup_list_dict
=
{}
# Open the file in read mode
with
open
(
file_path
,
'r'
)
as
file
:
# Read all lines from the file and store them in a list
lines
=
file
.
readlines
()
for
line
in
lines
:
if
line
.
strip
()
==
''
:
break
verification_list
.
append
(
line
.
split
(
' '
)[
1
])
if
'fixup!'
in
line
:
fixup_commit
=
line
.
strip
()
fixup_original_message
=
fixup_commit
.
split
(
'fixup! '
)[
-
1
]
already_found
=
False
for
original_commit
in
original_commit_list
:
if
fixup_original_message
in
original_commit
:
assert
not
already_found
original_to_fixup_list_dict
[
original_commit
]
=
original_to_fixup_list_dict
.
get
(
original_commit
,
[])
+
[
fixup_commit
.
replace
(
'pick'
,
'f'
,
1
)]
already_found
=
True
if
already_found
:
fixup_commit_list
.
append
(
fixup_commit
)
else
:
original_commit_list
.
append
(
line
.
strip
())
else
:
original_commit_list
.
append
(
line
.
strip
())
result_list
=
[]
for
original_commit
in
original_commit_list
:
result_list
.
append
(
original_commit
)
fixup_commit_sub_list
=
original_to_fixup_list_dict
.
get
(
original_commit
,
False
)
if
fixup_commit_sub_list
:
for
fixup_commit
in
fixup_commit_sub_list
:
result_list
.
append
(
fixup_commit
)
assert
len
(
original_commit_list
)
+
len
(
fixup_commit_list
)
==
len
(
result_list
),
'%d %d'
%
(
len
(
lines
),
len
(
result_list
))
result_string
=
'
\
n
'
.
join
(
result_list
)
for
hash
in
verification_list
:
assert
hash
in
result_string
#print('\n'.join(result_list))
with
open
(
file_path
,
'w'
)
as
file
:
file
.
write
(
result_string
)
"""
# Print the list of lines
print(fixup_commit_list)
print(original_commit_list)
pick 0187235284 fixup! sanef_fr_base: Add Process Suspended Subscription Request alarm
"""
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment