Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
edacfbf8
Commit
edacfbf8
authored
Feb 06, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'squash-binary-files' into 'master'
Squash binary files See merge request !1174
parents
cd3ae49b
1a5fcdd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
23 deletions
+33
-23
app/services/merge_requests/squash_service.rb
app/services/merge_requests/squash_service.rb
+9
-7
app/services/merge_requests/working_copy_base_service.rb
app/services/merge_requests/working_copy_base_service.rb
+11
-4
doc/user/project/merge_requests/squash_and_merge.md
doc/user/project/merge_requests/squash_and_merge.md
+1
-1
spec/services/merge_requests/squash_service_spec.rb
spec/services/merge_requests/squash_service_spec.rb
+12
-11
No files found.
app/services/merge_requests/squash_service.rb
View file @
edacfbf8
...
...
@@ -29,9 +29,15 @@ module MergeRequests
'add worktree for squash'
)
run_git_command
(
%w(apply --cached)
,
tree_path
,
git_env
,
'apply patch'
)
do
|
stdin
|
stdin
.
puts
(
merge_request_to_patch
)
end
diff
=
git_command
(
%W(diff --binary
#{
merge_request
.
diff_start_sha
}
...
#{
merge_request
.
diff_head_sha
}
)
)
apply
=
git_command
(
%w(apply --index)
)
run_command
(
[
"
#{
diff
.
join
(
' '
)
}
|
#{
apply
.
join
(
' '
)
}
"
],
tree_path
,
git_env
,
'apply patch'
)
run_git_command
(
%W(commit -C
#{
merge_request
.
diff_head_sha
}
)
,
...
...
@@ -61,9 +67,5 @@ module MergeRequests
def
tree_path
@tree_path
||=
merge_request
.
squash_dir_path
end
def
merge_request_to_patch
@merge_request_to_patch
||=
rugged
.
diff
(
merge_request
.
diff_base_sha
,
merge_request
.
diff_head_sha
).
patch
end
end
end
app/services/merge_requests/working_copy_base_service.rb
View file @
edacfbf8
...
...
@@ -6,15 +6,22 @@ module MergeRequests
attr_reader
:merge_request
def
git_command
(
command
)
[
Gitlab
.
config
.
git
.
bin_path
]
+
command
end
def
run_git_command
(
command
,
path
,
env
,
message
=
nil
,
&
block
)
git_command
=
[
Gitlab
.
config
.
git
.
bin_path
]
+
command
output
,
status
=
popen
(
git_command
,
path
,
env
,
&
block
)
run_command
(
git_command
(
command
),
path
,
env
,
message
,
&
block
)
end
def
run_command
(
command
,
path
,
env
,
message
=
nil
,
&
block
)
output
,
status
=
popen
(
command
,
path
,
env
,
&
block
)
unless
status
.
zero?
if
message
log_error
(
"Failed to
#{
message
}
with `
#{
git_
command
.
join
(
' '
)
}
`:"
)
log_error
(
"Failed to
#{
message
}
with `
#{
command
.
join
(
' '
)
}
`:"
)
else
log_error
(
"`
#{
git_
command
.
join
(
' '
)
}
` failed:"
)
log_error
(
"`
#{
command
.
join
(
' '
)
}
` failed:"
)
end
log_error
(
output
)
...
...
doc/user/project/merge_requests/squash_and_merge.md
View file @
edacfbf8
# Squash and merge
> [Introduced][ee-1024] in GitLab Enterprise Edition 8.1
6
.
> [Introduced][ee-1024] in GitLab Enterprise Edition 8.1
7
.
Squashing lets you tidy up the commit history of a branch when accepting a merge
request. It applies all of the changes in the merge request as a single commit,
...
...
spec/services/merge_requests/squash_service_spec.rb
View file @
edacfbf8
...
...
@@ -7,7 +7,7 @@ describe MergeRequests::SquashService do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_branch:
'
fix
'
,
source_project:
project
,
source_branch:
'
video
'
,
source_project:
project
,
target_branch:
'master'
,
target_project:
project
)
end
...
...
@@ -17,13 +17,6 @@ describe MergeRequests::SquashService do
target_branch:
'master'
,
target_project:
project
)
end
def
git_command
(
command
)
a_collection_starting_with
([
Gitlab
.
config
.
git
.
bin_path
,
command
])
end
shared_examples
'the squashed commit'
do
end
describe
'#execute'
do
context
'when there is only one commit in the merge request'
do
it
'returns that commit SHA'
do
...
...
@@ -66,7 +59,9 @@ describe MergeRequests::SquashService do
expect
(
squash_commit
.
author_name
).
to
eq
(
diff_head_commit
.
author_name
)
expect
(
squash_commit
.
author_email
).
to
eq
(
diff_head_commit
.
author_email
)
expect
(
squash_commit
.
message
).
to
eq
(
diff_head_commit
.
message
)
# The commit message on the 'real' commit doesn't have a trailing newline
expect
(
squash_commit
.
message
.
chomp
).
to
eq
(
diff_head_commit
.
message
)
end
it
'sets the current user as the committer'
do
...
...
@@ -87,7 +82,7 @@ describe MergeRequests::SquashService do
stages
=
{
'add worktree for squash'
=>
'worktree'
,
'apply patch'
=>
'
appl
y'
,
'apply patch'
=>
'
diff --binar
y'
,
'commit squashed changes'
=>
'commit'
,
'get SHA of squashed commit'
=>
'rev-parse'
}
...
...
@@ -97,8 +92,14 @@ describe MergeRequests::SquashService do
let
(
:error
)
{
'A test error'
}
before
do
git_command
=
a_collection_containing_exactly
(
a_string_starting_with
(
"
#{
Gitlab
.
config
.
git
.
bin_path
}
#{
command
}
"
)
).
or
(
a_collection_starting_with
([
Gitlab
.
config
.
git
.
bin_path
,
command
])
)
allow
(
service
).
to
receive
(
:popen
).
and_return
([
''
,
0
])
allow
(
service
).
to
receive
(
:popen
).
with
(
git_command
(
command
)
,
anything
,
anything
).
and_return
([
error
,
1
])
allow
(
service
).
to
receive
(
:popen
).
with
(
git_command
,
anything
,
anything
).
and_return
([
error
,
1
])
end
it
'logs the stage and output'
do
...
...
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