Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
83997d0e
Commit
83997d0e
authored
Feb 18, 2021
by
Waqar Ahmed
Browse files
Allow signing-off commit messages using commit dialog
Signed-off-by:
Waqar Ahmed
<
waqar.17a@gmail.com
>
parent
0222a815
Changes
4
Hide whitespace changes
Inline
Side-by-side
addons/project/gitcommitdialog.cpp
View file @
83997d0e
...
...
@@ -111,6 +111,10 @@ GitCommitDialog::GitCommitDialog(const QString &lastCommit, const QFont &font, Q
}
}
m_cbSignOff
.
setChecked
(
false
);
m_cbSignOff
.
setText
(
i18n
(
"Sign off"
));
vlayout
->
addWidget
(
&
m_cbSignOff
);
QHBoxLayout
*
hLayout
=
new
QHBoxLayout
;
hLayout
->
addStretch
();
hLayout
->
addWidget
(
&
ok
);
...
...
@@ -121,9 +125,6 @@ GitCommitDialog::GitCommitDialog(const QString &lastCommit, const QFont &font, Q
connect
(
m_le
,
&
QPlainTextEdit
::
textChanged
,
this
,
&
GitCommitDialog
::
updateLineSizeLabel
);
updateLineSizeLabel
();
// m_cbSeventyTwoLimit.setText(i18n("Automatically break description into 72 or less character lines"));
// m_cbSeventyTwoLimit.setChecked(true);
// vlayout->addWidget(&m_cbSeventyTwoLimit);
vlayout
->
addLayout
(
hLayout
);
}
...
...
@@ -138,6 +139,11 @@ QString GitCommitDialog::description() const
return
m_pe
.
toPlainText
();
}
bool
GitCommitDialog
::
signoff
()
const
{
return
m_cbSignOff
.
isChecked
();
}
void
GitCommitDialog
::
updateLineSizeLabel
()
{
int
len
=
m_le
->
textLength
();
...
...
addons/project/gitcommitdialog.h
View file @
83997d0e
#ifndef GITCOMMITDIALOG_H
/*
SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef GITCOMMITDIALOG_H
#define GITCOMMITDIALOG_H
#include <QCheckBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QPushButton>
#include <memory>
class
SingleLineEdit
;
class
BadLengthHighlighter
;
...
...
@@ -27,6 +26,7 @@ public:
QString
subject
()
const
;
QString
description
()
const
;
bool
signoff
()
const
;
private:
Q_SLOT
void
updateLineSizeLabel
();
...
...
@@ -37,6 +37,7 @@ private:
QPushButton
cancel
;
QLabel
m_leLen
;
QLabel
m_peLen
;
QCheckBox
m_cbSignOff
;
BadLengthHighlighter
*
m_hl
;
};
...
...
addons/project/gitwidget.cpp
View file @
83997d0e
...
...
@@ -328,9 +328,14 @@ void GitWidget::launchExternalDiffTool(const QString &file, bool staged)
git
.
start
();
}
void
GitWidget
::
commitChanges
(
const
QString
&
msg
,
const
QString
&
desc
)
void
GitWidget
::
commitChanges
(
const
QString
&
msg
,
const
QString
&
desc
,
bool
signOff
)
{
auto
args
=
QStringList
{
QStringLiteral
(
"commit"
),
QStringLiteral
(
"-m"
),
msg
};
auto
args
=
QStringList
{
QStringLiteral
(
"commit"
)};
if
(
signOff
)
{
args
.
append
(
QStringLiteral
(
"-s"
));
}
args
.
append
(
QStringLiteral
(
"-m"
));
args
.
append
(
msg
);
if
(
!
desc
.
isEmpty
())
{
args
.
append
(
QStringLiteral
(
"-m"
));
args
.
append
(
desc
);
...
...
@@ -347,6 +352,7 @@ void GitWidget::commitChanges(const QString &msg, const QString &desc)
sendMessage
(
i18n
(
"Failed to commit.
\n
%1"
,
QString
::
fromUtf8
(
git
.
readAllStandardError
())),
true
);
}
else
{
sendMessage
(
i18n
(
"Changes committed successfully."
),
false
);
m_commitMessage
.
clear
();
// refresh
getStatus
();
}
...
...
@@ -375,9 +381,8 @@ void GitWidget::opencommitChangesDialog()
if
(
dialog
.
subject
().
isEmpty
())
{
return
sendMessage
(
i18n
(
"Commit message cannot be empty."
),
true
);
}
commitChanges
(
dialog
.
subject
(),
dialog
.
description
());
}
else
{
m_commitMessage
=
dialog
.
subject
()
+
QStringLiteral
(
"[[
\n\n
]]"
)
+
dialog
.
description
();
commitChanges
(
dialog
.
subject
(),
dialog
.
description
(),
dialog
.
signoff
());
}
}
...
...
addons/project/gitwidget.h
View file @
83997d0e
...
...
@@ -64,7 +64,7 @@ private:
void
openAtHEAD
(
const
QString
&
file
);
void
showDiff
(
const
QString
&
file
,
bool
staged
);
void
launchExternalDiffTool
(
const
QString
&
file
,
bool
staged
);
void
commitChanges
(
const
QString
&
msg
,
const
QString
&
desc
);
void
commitChanges
(
const
QString
&
msg
,
const
QString
&
desc
,
bool
signOff
);
void
sendMessage
(
const
QString
&
message
,
bool
warn
);
void
hideEmptyTreeNodes
();
...
...
Write
Preview
Supports
Markdown
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