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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
faa2e2df
Commit
faa2e2df
authored
Feb 15, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename commit_file, commit_dir and remove_file and update specs
parent
0625af3b
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
86 additions
and
102 deletions
+86
-102
app/models/repository.rb
app/models/repository.rb
+6
-8
app/services/files/create_dir_service.rb
app/services/files/create_dir_service.rb
+1
-1
app/services/files/create_service.rb
app/services/files/create_service.rb
+1
-2
app/services/files/destroy_service.rb
app/services/files/destroy_service.rb
+1
-1
db/fixtures/development/17_cycle_analytics.rb
db/fixtures/development/17_cycle_analytics.rb
+1
-1
spec/controllers/projects/templates_controller_spec.rb
spec/controllers/projects/templates_controller_spec.rb
+2
-2
spec/factories/projects.rb
spec/factories/projects.rb
+6
-9
spec/features/projects/files/project_owner_creates_license_file_spec.rb
...projects/files/project_owner_creates_license_file_spec.rb
+1
-1
spec/features/projects/issuable_templates_spec.rb
spec/features/projects/issuable_templates_spec.rb
+10
-15
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+2
-3
spec/models/cycle_analytics/production_spec.rb
spec/models/cycle_analytics/production_spec.rb
+2
-3
spec/models/cycle_analytics/staging_spec.rb
spec/models/cycle_analytics/staging_spec.rb
+2
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+45
-45
spec/services/merge_requests/resolve_service_spec.rb
spec/services/merge_requests/resolve_service_spec.rb
+2
-3
spec/support/cycle_analytics_helpers.rb
spec/support/cycle_analytics_helpers.rb
+3
-4
No files found.
app/models/repository.rb
View file @
faa2e2df
...
@@ -747,7 +747,7 @@ class Repository
...
@@ -747,7 +747,7 @@ class Repository
end
end
# rubocop:disable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
c
ommit
_dir
(
def
c
reate
_dir
(
user
,
path
,
user
,
path
,
message
:,
branch_name
:,
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
...
@@ -778,14 +778,12 @@ class Repository
...
@@ -778,14 +778,12 @@ class Repository
# rubocop:enable Metrics/ParameterLists
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
c
ommit
_file
(
def
c
reate
_file
(
user
,
path
,
content
,
user
,
path
,
content
,
message
:,
branch_name
:,
update:
true
,
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
start_branch_name:
nil
,
start_project:
project
)
action
=
update
?
:update
:
:create
multi_action
(
multi_action
(
user:
user
,
user:
user
,
message:
message
,
message:
message
,
...
@@ -794,7 +792,7 @@ class Repository
...
@@ -794,7 +792,7 @@ class Repository
author_name:
author_name
,
author_name:
author_name
,
start_branch_name:
start_branch_name
,
start_branch_name:
start_branch_name
,
start_project:
start_project
,
start_project:
start_project
,
actions:
[{
action:
action
,
actions:
[{
action:
:create
,
file_path:
path
,
file_path:
path
,
content:
content
}])
content:
content
}])
end
end
...
@@ -803,7 +801,7 @@ class Repository
...
@@ -803,7 +801,7 @@ class Repository
# rubocop:disable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
update_file
(
def
update_file
(
user
,
path
,
content
,
user
,
path
,
content
,
message
:,
branch_name
:,
previous_path
:,
message
:,
branch_name
:,
previous_path:
nil
,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
start_branch_name:
nil
,
start_project:
project
)
action
=
if
previous_path
&&
previous_path
!=
path
action
=
if
previous_path
&&
previous_path
!=
path
...
@@ -828,7 +826,7 @@ class Repository
...
@@ -828,7 +826,7 @@ class Repository
# rubocop:enable Metrics/ParameterLists
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
remov
e_file
(
def
delet
e_file
(
user
,
path
,
user
,
path
,
message
:,
branch_name
:,
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
...
...
app/services/files/create_dir_service.rb
View file @
faa2e2df
module
Files
module
Files
class
CreateDirService
<
Files
::
BaseService
class
CreateDirService
<
Files
::
BaseService
def
commit
def
commit
repository
.
c
ommit
_dir
(
repository
.
c
reate
_dir
(
current_user
,
current_user
,
@file_path
,
@file_path
,
message:
@commit_message
,
message:
@commit_message
,
...
...
app/services/files/create_service.rb
View file @
faa2e2df
module
Files
module
Files
class
CreateService
<
Files
::
BaseService
class
CreateService
<
Files
::
BaseService
def
commit
def
commit
repository
.
c
ommit
_file
(
repository
.
c
reate
_file
(
current_user
,
current_user
,
@file_path
,
@file_path
,
@file_content
,
@file_content
,
message:
@commit_message
,
message:
@commit_message
,
branch_name:
@target_branch
,
branch_name:
@target_branch
,
update:
false
,
author_email:
@author_email
,
author_email:
@author_email
,
author_name:
@author_name
,
author_name:
@author_name
,
start_project:
@start_project
,
start_project:
@start_project
,
...
...
app/services/files/destroy_service.rb
View file @
faa2e2df
module
Files
module
Files
class
DestroyService
<
Files
::
BaseService
class
DestroyService
<
Files
::
BaseService
def
commit
def
commit
repository
.
remov
e_file
(
repository
.
delet
e_file
(
current_user
,
current_user
,
@file_path
,
@file_path
,
message:
@commit_message
,
message:
@commit_message
,
...
...
db/fixtures/development/17_cycle_analytics.rb
View file @
faa2e2df
...
@@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics
...
@@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics
issue
.
project
.
repository
.
add_branch
(
@user
,
branch_name
,
'master'
)
issue
.
project
.
repository
.
add_branch
(
@user
,
branch_name
,
'master'
)
commit_sha
=
issue
.
project
.
repository
.
c
ommit
_file
(
@user
,
filename
,
"content"
,
options
,
message:
"Commit for #
#{
issue
.
iid
}
"
,
branch_name:
branch_name
)
commit_sha
=
issue
.
project
.
repository
.
c
reate
_file
(
@user
,
filename
,
"content"
,
options
,
message:
"Commit for #
#{
issue
.
iid
}
"
,
branch_name:
branch_name
)
issue
.
project
.
repository
.
commit
(
commit_sha
)
issue
.
project
.
repository
.
commit
(
commit_sha
)
GitPushService
.
new
(
issue
.
project
,
GitPushService
.
new
(
issue
.
project
,
...
...
spec/controllers/projects/templates_controller_spec.rb
View file @
faa2e2df
...
@@ -14,8 +14,8 @@ describe Projects::TemplatesController do
...
@@ -14,8 +14,8 @@ describe Projects::TemplatesController do
before
do
before
do
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
project
.
repository
.
c
ommit
_file
(
user
,
file_path_1
,
'something valid'
,
project
.
repository
.
c
reate
_file
(
user
,
file_path_1
,
'something valid'
,
message:
'test 3'
,
branch_name:
'master'
,
update:
false
)
message:
'test 3'
,
branch_name:
'master'
)
end
end
describe
'#show'
do
describe
'#show'
do
...
...
spec/factories/projects.rb
View file @
faa2e2df
...
@@ -138,27 +138,24 @@ FactoryGirl.define do
...
@@ -138,27 +138,24 @@ FactoryGirl.define do
project
.
add_user
(
args
[
:user
],
args
[
:access
])
project
.
add_user
(
args
[
:user
],
args
[
:access
])
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
args
[
:user
],
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/bug.md"
,
".gitlab/
#{
args
[
:path
]
}
/bug.md"
,
'something valid'
,
'something valid'
,
message:
'test 3'
,
message:
'test 3'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
project
.
repository
.
create_file
(
project
.
repository
.
commit_file
(
args
[
:user
],
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/template_test.md"
,
".gitlab/
#{
args
[
:path
]
}
/template_test.md"
,
'template_test'
,
'template_test'
,
message:
'test 1'
,
message:
'test 1'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
project
.
repository
.
create_file
(
project
.
repository
.
commit_file
(
args
[
:user
],
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/feature_proposal.md"
,
".gitlab/
#{
args
[
:path
]
}
/feature_proposal.md"
,
'feature_proposal'
,
'feature_proposal'
,
message:
'test 2'
,
message:
'test 2'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
end
end
end
end
end
end
...
...
spec/features/projects/files/project_owner_creates_license_file_spec.rb
View file @
faa2e2df
...
@@ -6,7 +6,7 @@ feature 'project owner creates a license file', feature: true, js: true do
...
@@ -6,7 +6,7 @@ feature 'project owner creates a license file', feature: true, js: true do
let
(
:project_master
)
{
create
(
:user
)
}
let
(
:project_master
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
background
do
background
do
project
.
repository
.
remov
e_file
(
project_master
,
'LICENSE'
,
project
.
repository
.
delet
e_file
(
project_master
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'master'
)
message:
'Remove LICENSE'
,
branch_name:
'master'
)
project
.
team
<<
[
project_master
,
:master
]
project
.
team
<<
[
project_master
,
:master
]
login_as
(
project_master
)
login_as
(
project_master
)
...
...
spec/features/projects/issuable_templates_spec.rb
View file @
faa2e2df
...
@@ -18,20 +18,18 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -18,20 +18,18 @@ feature 'issuable templates', feature: true, js: true do
let
(
:description_addition
)
{
' appending to description'
}
let
(
:description_addition
)
{
' appending to description'
}
background
do
background
do
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
user
,
user
,
'.gitlab/issue_templates/bug.md'
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
template_content
,
message:
'added issue template'
,
message:
'added issue template'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
project
.
repository
.
create_file
(
project
.
repository
.
commit_file
(
user
,
user
,
'.gitlab/issue_templates/test.md'
,
'.gitlab/issue_templates/test.md'
,
longtemplate_content
,
longtemplate_content
,
message:
'added issue template'
,
message:
'added issue template'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[title]'
,
with:
'test issue title'
end
end
...
@@ -79,13 +77,12 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -79,13 +77,12 @@ feature 'issuable templates', feature: true, js: true do
let
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
background
do
background
do
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
user
,
user
,
'.gitlab/issue_templates/bug.md'
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
template_content
,
message:
'added issue template'
,
message:
'added issue template'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[description]'
,
with:
prior_description
fill_in
:'issue[description]'
,
with:
prior_description
...
@@ -104,13 +101,12 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -104,13 +101,12 @@ feature 'issuable templates', feature: true, js: true do
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
project
)
}
background
do
background
do
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
user
,
user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
template_content
,
message:
'added merge request template'
,
message:
'added merge request template'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
end
end
...
@@ -135,13 +131,12 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -135,13 +131,12 @@ feature 'issuable templates', feature: true, js: true do
fork_project
.
team
<<
[
fork_user
,
:master
]
fork_project
.
team
<<
[
fork_user
,
:master
]
create
(
:forked_project_link
,
forked_to_project:
fork_project
,
forked_from_project:
project
)
create
(
:forked_project_link
,
forked_to_project:
fork_project
,
forked_from_project:
project
)
login_as
fork_user
login_as
fork_user
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
fork_user
,
fork_user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
template_content
,
message:
'added merge request template'
,
message:
'added merge request template'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
faa2e2df
...
@@ -209,13 +209,12 @@ describe Gitlab::GitAccess, lib: true do
...
@@ -209,13 +209,12 @@ describe Gitlab::GitAccess, lib: true do
stub_git_hooks
stub_git_hooks
project
.
repository
.
add_branch
(
user
,
unprotected_branch
,
'feature'
)
project
.
repository
.
add_branch
(
user
,
unprotected_branch
,
'feature'
)
target_branch
=
project
.
repository
.
lookup
(
'feature'
)
target_branch
=
project
.
repository
.
lookup
(
'feature'
)
source_branch
=
project
.
repository
.
c
ommit
_file
(
source_branch
=
project
.
repository
.
c
reate
_file
(
user
,
user
,
FFaker
::
InternetSE
.
login_user_name
,
FFaker
::
InternetSE
.
login_user_name
,
FFaker
::
HipsterIpsum
.
paragraph
,
FFaker
::
HipsterIpsum
.
paragraph
,
message:
FFaker
::
HipsterIpsum
.
sentence
,
message:
FFaker
::
HipsterIpsum
.
sentence
,
branch_name:
unprotected_branch
,
branch_name:
unprotected_branch
)
update:
false
)
rugged
=
project
.
repository
.
rugged
rugged
=
project
.
repository
.
rugged
author
=
{
email:
"email@example.com"
,
time:
Time
.
now
,
name:
"Example Git User"
}
author
=
{
email:
"email@example.com"
,
time:
Time
.
now
,
name:
"Example Git User"
}
...
...
spec/models/cycle_analytics/production_spec.rb
View file @
faa2e2df
...
@@ -21,13 +21,12 @@ describe 'CycleAnalytics#production', feature: true do
...
@@ -21,13 +21,12 @@ describe 'CycleAnalytics#production', feature: true do
[
"production deploy happens after merge request is merged (along with other changes)"
,
[
"production deploy happens after merge request is merged (along with other changes)"
,
lambda
do
|
context
,
data
|
lambda
do
|
context
,
data
|
# Make other changes on master
# Make other changes on master
sha
=
context
.
project
.
repository
.
c
ommit
_file
(
sha
=
context
.
project
.
repository
.
c
reate
_file
(
context
.
user
,
context
.
user
,
context
.
random_git_name
,
context
.
random_git_name
,
'content'
,
'content'
,
message:
'commit message'
,
message:
'commit message'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
deploy_master
context
.
deploy_master
...
...
spec/models/cycle_analytics/staging_spec.rb
View file @
faa2e2df
...
@@ -26,13 +26,12 @@ describe 'CycleAnalytics#staging', feature: true do
...
@@ -26,13 +26,12 @@ describe 'CycleAnalytics#staging', feature: true do
[
"production deploy happens after merge request is merged (along with other changes)"
,
[
"production deploy happens after merge request is merged (along with other changes)"
,
lambda
do
|
context
,
data
|
lambda
do
|
context
,
data
|
# Make other changes on master
# Make other changes on master
sha
=
context
.
project
.
repository
.
c
ommit
_file
(
sha
=
context
.
project
.
repository
.
c
reate
_file
(
context
.
user
,
context
.
user
,
context
.
random_git_name
,
context
.
random_git_name
,
'content'
,
'content'
,
message:
'commit message'
,
message:
'commit message'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
deploy_master
context
.
deploy_master
...
...
spec/models/project_spec.rb
View file @
faa2e2df
...
@@ -1765,7 +1765,7 @@ describe Project, models: true do
...
@@ -1765,7 +1765,7 @@ describe Project, models: true do
end
end
before
do
before
do
project
.
repository
.
c
ommit_file
(
User
.
last
,
'.gitlab/route-map.yml'
,
route_map
,
message:
'Add .gitlab/route-map.yml'
,
branch_name:
'master'
,
update:
false
)
project
.
repository
.
c
reate_file
(
User
.
last
,
'.gitlab/route-map.yml'
,
route_map
,
message:
'Add .gitlab/route-map.yml'
,
branch_name:
'master'
)
end
end
context
'when there is a .gitlab/route-map.yml at the commit'
do
context
'when there is a .gitlab/route-map.yml at the commit'
do
...
...
spec/models/repository_spec.rb
View file @
faa2e2df
...
@@ -294,7 +294,7 @@ describe Repository, models: true do
...
@@ -294,7 +294,7 @@ describe Repository, models: true do
describe
"#commit_dir"
do
describe
"#commit_dir"
do
it
"commits a change that creates a new directory"
do
it
"commits a change that creates a new directory"
do
expect
do
expect
do
repository
.
c
ommit
_dir
(
user
,
'newdir'
,
repository
.
c
reate
_dir
(
user
,
'newdir'
,
message:
'Create newdir'
,
branch_name:
'master'
)
message:
'Create newdir'
,
branch_name:
'master'
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
...
@@ -307,7 +307,7 @@ describe Repository, models: true do
...
@@ -307,7 +307,7 @@ describe Repository, models: true do
it
"creates a fork and commit to the forked project"
do
it
"creates a fork and commit to the forked project"
do
expect
do
expect
do
repository
.
c
ommit
_dir
(
user
,
'newdir'
,
repository
.
c
reate
_dir
(
user
,
'newdir'
,
message:
'Create newdir'
,
branch_name:
'patch'
,
message:
'Create newdir'
,
branch_name:
'patch'
,
start_branch_name:
'master'
,
start_project:
forked_project
)
start_branch_name:
'master'
,
start_project:
forked_project
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
0
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
0
)
...
@@ -323,7 +323,7 @@ describe Repository, models: true do
...
@@ -323,7 +323,7 @@ describe Repository, models: true do
context
"when an author is specified"
do
context
"when an author is specified"
do
it
"uses the given email/name to set the commit's author"
do
it
"uses the given email/name to set the commit's author"
do
expect
do
expect
do
repository
.
c
ommit
_dir
(
user
,
'newdir'
,
repository
.
c
reate
_dir
(
user
,
'newdir'
,
message:
'Add newdir'
,
message:
'Add newdir'
,
branch_name:
'master'
,
branch_name:
'master'
,
author_email:
author_email
,
author_name:
author_name
)
author_email:
author_email
,
author_name:
author_name
)
...
@@ -337,25 +337,23 @@ describe Repository, models: true do
...
@@ -337,25 +337,23 @@ describe Repository, models: true do
end
end
end
end
describe
"#c
ommit
_file"
do
describe
"#c
reate
_file"
do
it
'commits
change to a
file successfully'
do
it
'commits
new
file successfully'
do
expect
do
expect
do
repository
.
commit_file
(
user
,
'CHANGELOG'
,
'Changelog!'
,
repository
.
create_file
(
user
,
'NEWCHANGELOG'
,
'Changelog!'
,
message:
'Updates file content'
,
message:
'Create changelog'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
true
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
blob
=
repository
.
blob_at
(
'master'
,
'CHANGELOG'
)
blob
=
repository
.
blob_at
(
'master'
,
'
NEW
CHANGELOG'
)
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
end
end
it
'respects the autocrlf setting'
do
it
'respects the autocrlf setting'
do
repository
.
c
ommit
_file
(
user
,
'hello.txt'
,
"Hello,
\r\n
World"
,
repository
.
c
reate
_file
(
user
,
'hello.txt'
,
"Hello,
\r\n
World"
,
message:
'Add hello world'
,
message:
'Add hello world'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
blob
=
repository
.
blob_at
(
'master'
,
'hello.txt'
)
blob
=
repository
.
blob_at
(
'master'
,
'hello.txt'
)
...
@@ -365,10 +363,9 @@ describe Repository, models: true do
...
@@ -365,10 +363,9 @@ describe Repository, models: true do
context
"when an author is specified"
do
context
"when an author is specified"
do
it
"uses the given email/name to set the commit's author"
do
it
"uses the given email/name to set the commit's author"
do
expect
do
expect
do
repository
.
c
ommit_file
(
user
,
'
README'
,
'README!'
,
repository
.
c
reate_file
(
user
,
'NEW
README'
,
'README!'
,
message:
'Add README'
,
message:
'Add README'
,
branch_name:
'master'
,
branch_name:
'master'
,
update:
true
,
author_email:
author_email
,
author_email:
author_email
,
author_name:
author_name
)
author_name:
author_name
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
...
@@ -382,6 +379,18 @@ describe Repository, models: true do
...
@@ -382,6 +379,18 @@ describe Repository, models: true do
end
end
describe
"#update_file"
do
describe
"#update_file"
do
it
'updates file successfully'
do
expect
do
repository
.
update_file
(
user
,
'CHANGELOG'
,
'Changelog!'
,
message:
'Update changelog'
,
branch_name:
'master'
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
blob
=
repository
.
blob_at
(
'master'
,
'CHANGELOG'
)
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
end
it
'updates filename successfully'
do
it
'updates filename successfully'
do
expect
do
expect
do
repository
.
update_file
(
user
,
'NEWLICENSE'
,
'Copyright!'
,
repository
.
update_file
(
user
,
'NEWLICENSE'
,
'Copyright!'
,
...
@@ -398,8 +407,6 @@ describe Repository, models: true do
...
@@ -398,8 +407,6 @@ describe Repository, models: true do
context
"when an author is specified"
do
context
"when an author is specified"
do
it
"uses the given email/name to set the commit's author"
do
it
"uses the given email/name to set the commit's author"
do
repository
.
commit_file
(
user
,
'README'
,
'README!'
,
message:
'Add README'
,
branch_name:
'master'
,
update:
true
)
expect
do
expect
do
repository
.
update_file
(
user
,
'README'
,
'Updated README!'
,
repository
.
update_file
(
user
,
'README'
,
'Updated README!'
,
...
@@ -420,11 +427,8 @@ describe Repository, models: true do
...
@@ -420,11 +427,8 @@ describe Repository, models: true do
describe
"#remove_file"
do
describe
"#remove_file"
do
it
'removes file successfully'
do
it
'removes file successfully'
do
repository
.
commit_file
(
user
,
'README'
,
'README!'
,
message:
'Add README'
,
branch_name:
'master'
,
update:
true
)
expect
do
expect
do
repository
.
remov
e_file
(
user
,
'README'
,
repository
.
delet
e_file
(
user
,
'README'
,
message:
'Remove README'
,
branch_name:
'master'
)
message:
'Remove README'
,
branch_name:
'master'
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
...
@@ -433,11 +437,8 @@ describe Repository, models: true do
...
@@ -433,11 +437,8 @@ describe Repository, models: true do
context
"when an author is specified"
do
context
"when an author is specified"
do
it
"uses the given email/name to set the commit's author"
do
it
"uses the given email/name to set the commit's author"
do
repository
.
commit_file
(
user
,
'README'
,
'README!'
,
message:
'Add README'
,
branch_name:
'master'
,
update:
true
)
expect
do
expect
do
repository
.
remov
e_file
(
user
,
'README'
,
repository
.
delet
e_file
(
user
,
'README'
,
message:
'Remove README'
,
branch_name:
'master'
,
message:
'Remove README'
,
branch_name:
'master'
,
author_email:
author_email
,
author_name:
author_name
)
author_email:
author_email
,
author_name:
author_name
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
...
@@ -587,14 +588,14 @@ describe Repository, models: true do
...
@@ -587,14 +588,14 @@ describe Repository, models: true do
describe
"#license_blob"
,
caching:
true
do
describe
"#license_blob"
,
caching:
true
do
before
do
before
do
repository
.
remov
e_file
(
repository
.
delet
e_file
(
user
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'master'
)
user
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'master'
)
end
end
it
'handles when HEAD points to non-existent ref'
do
it
'handles when HEAD points to non-existent ref'
do
repository
.
c
ommit
_file
(
repository
.
c
reate
_file
(
user
,
'LICENSE'
,
'Copyright!'
,
user
,
'LICENSE'
,
'Copyright!'
,
message:
'Add LICENSE'
,
branch_name:
'master'
,
update:
false
)
message:
'Add LICENSE'
,
branch_name:
'master'
)
allow
(
repository
).
to
receive
(
:file_on_head
).
allow
(
repository
).
to
receive
(
:file_on_head
).
and_raise
(
Rugged
::
ReferenceError
)
and_raise
(
Rugged
::
ReferenceError
)
...
@@ -603,27 +604,27 @@ describe Repository, models: true do
...
@@ -603,27 +604,27 @@ describe Repository, models: true do
end
end
it
'looks in the root_ref only'
do
it
'looks in the root_ref only'
do
repository
.
remov
e_file
(
user
,
'LICENSE'
,
repository
.
delet
e_file
(
user
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'markdown'
)
message:
'Remove LICENSE'
,
branch_name:
'markdown'
)
repository
.
c
ommit
_file
(
user
,
'LICENSE'
,
repository
.
c
reate
_file
(
user
,
'LICENSE'
,
Licensee
::
License
.
new
(
'mit'
).
content
,
Licensee
::
License
.
new
(
'mit'
).
content
,
message:
'Add LICENSE'
,
branch_name:
'markdown'
,
update:
false
)
message:
'Add LICENSE'
,
branch_name:
'markdown'
)
expect
(
repository
.
license_blob
).
to
be_nil
expect
(
repository
.
license_blob
).
to
be_nil
end
end
it
'detects license file with no recognizable open-source license content'
do
it
'detects license file with no recognizable open-source license content'
do
repository
.
c
ommit
_file
(
user
,
'LICENSE'
,
'Copyright!'
,
repository
.
c
reate
_file
(
user
,
'LICENSE'
,
'Copyright!'
,
message:
'Add LICENSE'
,
branch_name:
'master'
,
update:
false
)
message:
'Add LICENSE'
,
branch_name:
'master'
)
expect
(
repository
.
license_blob
.
name
).
to
eq
(
'LICENSE'
)
expect
(
repository
.
license_blob
.
name
).
to
eq
(
'LICENSE'
)
end
end
%w[LICENSE LICENCE LiCensE LICENSE.md LICENSE.foo COPYING COPYING.md]
.
each
do
|
filename
|
%w[LICENSE LICENCE LiCensE LICENSE.md LICENSE.foo COPYING COPYING.md]
.
each
do
|
filename
|
it
"detects '
#{
filename
}
'"
do
it
"detects '
#{
filename
}
'"
do
repository
.
c
ommit
_file
(
user
,
filename
,
repository
.
c
reate
_file
(
user
,
filename
,
Licensee
::
License
.
new
(
'mit'
).
content
,
Licensee
::
License
.
new
(
'mit'
).
content
,
message:
"Add
#{
filename
}
"
,
branch_name:
'master'
,
update:
false
)
message:
"Add
#{
filename
}
"
,
branch_name:
'master'
)
expect
(
repository
.
license_blob
.
name
).
to
eq
(
filename
)
expect
(
repository
.
license_blob
.
name
).
to
eq
(
filename
)
end
end
...
@@ -632,7 +633,7 @@ describe Repository, models: true do
...
@@ -632,7 +633,7 @@ describe Repository, models: true do
describe
'#license_key'
,
caching:
true
do
describe
'#license_key'
,
caching:
true
do
before
do
before
do
repository
.
remov
e_file
(
user
,
'LICENSE'
,
repository
.
delet
e_file
(
user
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'master'
)
message:
'Remove LICENSE'
,
branch_name:
'master'
)
end
end
...
@@ -647,16 +648,16 @@ describe Repository, models: true do
...
@@ -647,16 +648,16 @@ describe Repository, models: true do
end
end
it
'detects license file with no recognizable open-source license content'
do
it
'detects license file with no recognizable open-source license content'
do
repository
.
c
ommit
_file
(
user
,
'LICENSE'
,
'Copyright!'
,
repository
.
c
reate
_file
(
user
,
'LICENSE'
,
'Copyright!'
,
message:
'Add LICENSE'
,
branch_name:
'master'
,
update:
false
)
message:
'Add LICENSE'
,
branch_name:
'master'
)
expect
(
repository
.
license_key
).
to
be_nil
expect
(
repository
.
license_key
).
to
be_nil
end
end
it
'returns the license key'
do
it
'returns the license key'
do
repository
.
c
ommit
_file
(
user
,
'LICENSE'
,
repository
.
c
reate
_file
(
user
,
'LICENSE'
,
Licensee
::
License
.
new
(
'mit'
).
content
,
Licensee
::
License
.
new
(
'mit'
).
content
,
message:
'Add LICENSE'
,
branch_name:
'master'
,
update:
false
)
message:
'Add LICENSE'
,
branch_name:
'master'
)
expect
(
repository
.
license_key
).
to
eq
(
'mit'
)
expect
(
repository
.
license_key
).
to
eq
(
'mit'
)
end
end
...
@@ -913,10 +914,9 @@ describe Repository, models: true do
...
@@ -913,10 +914,9 @@ describe Repository, models: true do
expect
(
empty_repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
empty_repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
empty_repository
).
to
receive
(
:expire_branches_cache
)
expect
(
empty_repository
).
to
receive
(
:expire_branches_cache
)
empty_repository
.
c
ommit
_file
(
user
,
'CHANGELOG'
,
'Changelog!'
,
empty_repository
.
c
reate
_file
(
user
,
'CHANGELOG'
,
'Changelog!'
,
message:
'Updates file content'
,
message:
'Updates file content'
,
branch_name:
'master'
,
branch_name:
'master'
)
update:
false
)
end
end
end
end
end
end
...
@@ -1796,7 +1796,7 @@ describe Repository, models: true do
...
@@ -1796,7 +1796,7 @@ describe Repository, models: true do
describe
'#gitlab_ci_yml_for'
do
describe
'#gitlab_ci_yml_for'
do
before
do
before
do
repository
.
c
ommit_file
(
User
.
last
,
'.gitlab-ci.yml'
,
'CONTENT'
,
message:
'Add .gitlab-ci.yml'
,
branch_name:
'master'
,
update:
false
)
repository
.
c
reate_file
(
User
.
last
,
'.gitlab-ci.yml'
,
'CONTENT'
,
message:
'Add .gitlab-ci.yml'
,
branch_name:
'master'
)
end
end
context
'when there is a .gitlab-ci.yml at the commit'
do
context
'when there is a .gitlab-ci.yml at the commit'
do
...
@@ -1814,7 +1814,7 @@ describe Repository, models: true do
...
@@ -1814,7 +1814,7 @@ describe Repository, models: true do
describe
'#route_map_for'
do
describe
'#route_map_for'
do
before
do
before
do
repository
.
c
ommit_file
(
User
.
last
,
'.gitlab/route-map.yml'
,
'CONTENT'
,
message:
'Add .gitlab/route-map.yml'
,
branch_name:
'master'
,
update:
false
)
repository
.
c
reate_file
(
User
.
last
,
'.gitlab/route-map.yml'
,
'CONTENT'
,
message:
'Add .gitlab/route-map.yml'
,
branch_name:
'master'
)
end
end
context
'when there is a .gitlab/route-map.yml at the commit'
do
context
'when there is a .gitlab/route-map.yml at the commit'
do
...
...
spec/services/merge_requests/resolve_service_spec.rb
View file @
faa2e2df
...
@@ -66,13 +66,12 @@ describe MergeRequests::ResolveService do
...
@@ -66,13 +66,12 @@ describe MergeRequests::ResolveService do
context
'when the source project is a fork and does not contain the HEAD of the target branch'
do
context
'when the source project is a fork and does not contain the HEAD of the target branch'
do
let!
(
:target_head
)
do
let!
(
:target_head
)
do
project
.
repository
.
c
ommit
_file
(
project
.
repository
.
c
reate
_file
(
user
,
user
,
'new-file-in-target'
,
'new-file-in-target'
,
''
,
''
,
message:
'Add new file in target'
,
message:
'Add new file in target'
,
branch_name:
'conflict-start'
,
branch_name:
'conflict-start'
)
update:
false
)
end
end
before
do
before
do
...
...
spec/support/cycle_analytics_helpers.rb
View file @
faa2e2df
...
@@ -9,7 +9,7 @@ module CycleAnalyticsHelpers
...
@@ -9,7 +9,7 @@ module CycleAnalyticsHelpers
commit_shas
=
Array
.
new
(
count
)
do
|
index
|
commit_shas
=
Array
.
new
(
count
)
do
|
index
|
filename
=
random_git_name
filename
=
random_git_name
commit_sha
=
project
.
repository
.
c
ommit
_file
(
user
,
filename
,
"content"
,
message:
message
,
branch_name:
branch_name
)
commit_sha
=
project
.
repository
.
c
reate
_file
(
user
,
filename
,
"content"
,
message:
message
,
branch_name:
branch_name
)
project
.
repository
.
commit
(
commit_sha
)
project
.
repository
.
commit
(
commit_sha
)
commit_sha
commit_sha
...
@@ -28,13 +28,12 @@ module CycleAnalyticsHelpers
...
@@ -28,13 +28,12 @@ module CycleAnalyticsHelpers
project
.
repository
.
add_branch
(
user
,
source_branch
,
'master'
)
project
.
repository
.
add_branch
(
user
,
source_branch
,
'master'
)
end
end
sha
=
project
.
repository
.
c
ommit
_file
(
sha
=
project
.
repository
.
c
reate
_file
(
user
,
user
,
random_git_name
,
random_git_name
,
'content'
,
'content'
,
message:
'commit message'
,
message:
'commit message'
,
branch_name:
source_branch
,
branch_name:
source_branch
)
update:
false
)
project
.
repository
.
commit
(
sha
)
project
.
repository
.
commit
(
sha
)
opts
=
{
opts
=
{
...
...
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