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
Tatuya Kamada
gitlab-ce
Commits
89567373
Commit
89567373
authored
Nov 02, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a `--force` option to bin/changelog
parent
99a12e12
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
bin/changelog
bin/changelog
+7
-1
doc/development/changelog.md
doc/development/changelog.md
+19
-1
spec/bin/changelog_spec.rb
spec/bin/changelog_spec.rb
+12
-0
No files found.
bin/changelog
View file @
89567373
...
@@ -12,6 +12,7 @@ Options = Struct.new(
...
@@ -12,6 +12,7 @@ Options = Struct.new(
:amend
,
:amend
,
:author
,
:author
,
:dry_run
,
:dry_run
,
:force
,
:merge_request
,
:merge_request
,
:title
:title
)
)
...
@@ -29,6 +30,10 @@ class ChangelogOptionParser
...
@@ -29,6 +30,10 @@ class ChangelogOptionParser
options
.
amend
=
value
options
.
amend
=
value
end
end
opts
.
on
(
'-f'
,
'--force'
,
'Overwrite an existing entry'
)
do
|
value
|
options
.
force
=
value
end
opts
.
on
(
'-m'
,
'--merge-request [integer]'
,
Integer
,
'Merge Request ID'
)
do
|
value
|
opts
.
on
(
'-m'
,
'--merge-request [integer]'
,
Integer
,
'Merge Request ID'
)
do
|
value
|
options
.
merge_request
=
value
options
.
merge_request
=
value
end
end
...
@@ -111,8 +116,9 @@ class ChangelogEntry
...
@@ -111,8 +116,9 @@ class ChangelogEntry
def
assert_new_file!
def
assert_new_file!
return
unless
File
.
exist?
(
file_path
)
return
unless
File
.
exist?
(
file_path
)
return
if
options
.
force
fail_with
"
#{
file_path
}
already exists!"
fail_with
"
#{
file_path
}
already exists!
Use `--force` to overwrite.
"
end
end
def
assert_title!
def
assert_title!
...
...
doc/development/changelog.md
View file @
89567373
...
@@ -46,13 +46,14 @@ author:
...
@@ -46,13 +46,14 @@ author:
The entry filename is based on the name of the current Git branch. If you run
The entry filename is based on the name of the current Git branch. If you run
the command above on a branch called `feature/hey-dz`, it will generate a
the command above on a branch called `feature/hey-dz`, it will generate a
`changelogs/unreleased/feature-hey-dz` file.
`changelogs/unreleased/feature-hey-dz
.yml
` file.
### Arguments
### Arguments
| Argument | Shorthand | Purpose |
| Argument | Shorthand | Purpose |
| ----------------- | --------- | --------------------------------------------- |
| ----------------- | --------- | --------------------------------------------- |
| `--amend` | | Amend the previous commit |
| `--amend` | | Amend the previous commit |
| `--force` | `-f` | Overwrite an existing entry |
| `--merge-request` | `-m` | Merge Request ID |
| `--merge-request` | `-m` | Merge Request ID |
| `--dry-run` | `-n` | Don't actually write anything, just print |
| `--dry-run` | `-n` | Don't actually write anything, just print |
| `--git-username` | `-u` | Use Git user.name configuration as the author |
| `--git-username` | `-u` | Use Git user.name configuration as the author |
...
@@ -79,6 +80,23 @@ merge_request:
...
@@ -79,6 +80,23 @@ merge_request:
author:
author:
```
```
#### `--force` or `-f`
Use **`--force`** or **`-f`** to overwrite an existing changelog entry if it
already exists.
```
text
$ bin/changelog 'Hey DZ, I added a feature to GitLab!'
error changelogs/unreleased/feature-hey-dz.yml already exists! Use
`--force`
to overwrite.
$ bin/changelog 'Hey DZ, I added a feature to GitLab!' --force
create changelogs/unreleased/feature-hey-dz.yml
---
title: Hey DZ, I added a feature to GitLab!
merge_request: 1983
author:
```
#### `--merge-request` or `-m`
#### `--merge-request` or `-m`
Use the **`--merge-request`** or **`-m`** argument to provide the
Use the **`--merge-request`** or **`-m`** argument to provide the
...
...
spec/bin/changelog_spec.rb
View file @
89567373
...
@@ -10,6 +10,18 @@ describe 'bin/changelog' do
...
@@ -10,6 +10,18 @@ describe 'bin/changelog' do
expect
(
options
.
amend
).
to
eq
true
expect
(
options
.
amend
).
to
eq
true
end
end
it
'parses --force'
do
options
=
described_class
.
parse
(
%w[foo --force bar]
)
expect
(
options
.
force
).
to
eq
true
end
it
'parses -f'
do
options
=
described_class
.
parse
(
%w[foo -f bar]
)
expect
(
options
.
force
).
to
eq
true
end
it
'parses --merge-request'
do
it
'parses --merge-request'
do
options
=
described_class
.
parse
(
%w[foo --merge-request 1234 bar]
)
options
=
described_class
.
parse
(
%w[foo --merge-request 1234 bar]
)
...
...
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