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
df54458a
Commit
df54458a
authored
Jul 10, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Truncate filenames created by bin/changelog to 140 characters
parent
c6b67021
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
bin/changelog
bin/changelog
+10
-4
spec/bin/changelog_spec.rb
spec/bin/changelog_spec.rb
+14
-0
No files found.
bin/changelog
View file @
df54458a
...
@@ -23,6 +23,8 @@ module ChangelogHelpers
...
@@ -23,6 +23,8 @@ module ChangelogHelpers
Abort
=
Class
.
new
(
StandardError
)
Abort
=
Class
.
new
(
StandardError
)
Done
=
Class
.
new
(
StandardError
)
Done
=
Class
.
new
(
StandardError
)
MAX_FILENAME_LENGTH
=
140
# ecryptfs has a limit of 140 characters
def
capture_stdout
(
cmd
)
def
capture_stdout
(
cmd
)
output
=
IO
.
popen
(
cmd
,
&
:read
)
output
=
IO
.
popen
(
cmd
,
&
:read
)
fail_with
"command failed:
#{
cmd
.
join
(
' '
)
}
"
unless
$?
.
success?
fail_with
"command failed:
#{
cmd
.
join
(
' '
)
}
"
unless
$?
.
success?
...
@@ -142,7 +144,9 @@ class ChangelogEntry
...
@@ -142,7 +144,9 @@ class ChangelogEntry
def
initialize
(
options
)
def
initialize
(
options
)
@options
=
options
@options
=
options
end
def
execute
assert_feature_branch!
assert_feature_branch!
assert_title!
assert_title!
assert_new_file!
assert_new_file!
...
@@ -221,10 +225,12 @@ class ChangelogEntry
...
@@ -221,10 +225,12 @@ class ChangelogEntry
end
end
def
file_path
def
file_path
File
.
join
(
base_path
=
File
.
join
(
unreleased_path
,
unreleased_path
,
branch_name
.
gsub
(
/[^\w-]/
,
'-'
)
<<
'.yml'
branch_name
.
gsub
(
/[^\w-]/
,
'-'
))
)
# Add padding for .yml extension
base_path
[
0
..
MAX_FILENAME_LENGTH
-
5
]
+
'.yml'
end
end
def
unreleased_path
def
unreleased_path
...
@@ -250,7 +256,7 @@ end
...
@@ -250,7 +256,7 @@ end
if
$0
==
__FILE__
if
$0
==
__FILE__
begin
begin
options
=
ChangelogOptionParser
.
parse
(
ARGV
)
options
=
ChangelogOptionParser
.
parse
(
ARGV
)
ChangelogEntry
.
new
(
options
)
ChangelogEntry
.
new
(
options
)
.
execute
rescue
ChangelogHelpers
::
Abort
=>
ex
rescue
ChangelogHelpers
::
Abort
=>
ex
$stderr
.
puts
ex
.
message
$stderr
.
puts
ex
.
message
exit
1
exit
1
...
...
spec/bin/changelog_spec.rb
View file @
df54458a
...
@@ -3,6 +3,20 @@ require 'spec_helper'
...
@@ -3,6 +3,20 @@ require 'spec_helper'
load
File
.
expand_path
(
'../../bin/changelog'
,
__dir__
)
load
File
.
expand_path
(
'../../bin/changelog'
,
__dir__
)
describe
'bin/changelog'
do
describe
'bin/changelog'
do
let
(
:options
)
{
OpenStruct
.
new
(
title:
'Test title'
,
type:
'fixed'
,
dry_run:
true
)
}
describe
ChangelogEntry
do
it
'truncates the file path'
do
entry
=
described_class
.
new
(
options
)
allow
(
entry
).
to
receive
(
:ee?
).
and_return
(
false
)
allow
(
entry
).
to
receive
(
:branch_name
).
and_return
(
'long-branch-'
*
100
)
file_path
=
entry
.
send
(
:file_path
)
expect
(
file_path
.
length
).
to
eq
(
140
)
end
end
describe
ChangelogOptionParser
do
describe
ChangelogOptionParser
do
describe
'.parse'
do
describe
'.parse'
do
it
'parses --amend'
do
it
'parses --amend'
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