Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Tags for commit messages #1168

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e02888c
test[SKIP CI]
ylecuyer Dec 29, 2018
386b74e
[SKIP CI] tag
ylecuyer Dec 29, 2018
66570db
clean default config
ylecuyer Dec 29, 2018
b6e9a13
[SKIP CI] Clean code ES6
ylecuyer Dec 29, 2018
2122c87
Merge branch 'master' into tags
ylecuyer Jan 11, 2019
16e86b8
commitnpush
ylecuyer Jan 11, 2019
bedbc72
Merge branch 'master' into tags
ylecuyer Jan 23, 2019
d0c354a
Merge branch 'master' into tags
ylecuyer Jan 25, 2019
4485251
Merge branch 'master' into tags
Nov 18, 2019
fc507b4
es6
Nov 18, 2019
d7dfb6b
Merge branch 'master' into tags
ylecuyer Jan 7, 2020
99e4dc2
Merge branch 'master' into tags
ylecuyer Jan 28, 2020
c014dcc
Merge branch 'master' into tags
ylecuyer Feb 8, 2020
830ac8b
Merge branch 'master' into tags
ylecuyer Feb 23, 2020
209cbd6
Merge branch 'master' into tags
ylecuyer Apr 19, 2020
ff2e048
Merge branch 'master' into tags
ylecuyer Apr 27, 2020
708cf37
Merge branch 'master' into tags
ylecuyer Apr 27, 2020
ac8a19e
Merge branch 'master' into tags
ylecuyer May 1, 2020
218fc67
Merge branch 'master' into tags
ylecuyer May 14, 2020
909d330
fix merge issue
ylecuyer May 14, 2020
6d08544
prettier
ylecuyer May 14, 2020
00c2ff2
prettier + fix
ylecuyer May 14, 2020
e8ae2a8
Merge branch 'master' into tags
ylecuyer May 23, 2020
ab4c987
Merge branch 'master' into tags
ylecuyer Sep 21, 2020
67fa9f8
Merge branch 'master' into tags
ylecuyer Sep 25, 2020
ff38535
Merge branch 'master' into tags
Dec 17, 2020
38df2c2
Merge remote-tracking branch 'upstream/master' into tags
ylecuyer Jan 5, 2021
c2d64c4
Merge branch 'master' into tags
ylecuyer Feb 18, 2021
a7ff817
Merge branch 'master' into tags
ylecuyer Mar 12, 2021
d66c0b7
Merge branch 'master' into tags
ylecuyer May 6, 2021
3d94be5
Merge branch 'master' into tags
ylecuyer May 10, 2021
92bf687
Merge branch 'master' into tags
ylecuyer May 24, 2021
7b9c56a
Merge branch 'master' into tags
ylecuyer Nov 9, 2021
c6a5180
Merge branch 'master' into tags
ylecuyer Oct 29, 2022
42ab178
Merge branch 'master' into tags
Dec 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/staging/staging.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
</button>
<span class="commit-message-title-counter" data-bind="text: commitMessageTitleCount" />
</div>
<div data-bind="foreach: commitMessageTags">
<button class="tag-button btn btn-link" data-bind="click: toggle">
<div class="checkmark" data-bind="css: { checked: selected }">
<span
class="glyphicon"
data-bind="css: { 'glyphicon-check': selected, 'glyphicon-unchecked': !selected() }"
></span>
</div>
<span data-bind="text: text"></span>
</button>
</div>
<div class="btn-group commit-grp" data-bind="visible: isStageValid">
<button
class="btn btn-primary btn-lg commit-btn"
Expand Down
35 changes: 31 additions & 4 deletions components/staging/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ class StagingViewModel extends ComponentRoot {
this.stashIcon = octicons.pin.toSVG({ height: 15 });
this.discardIcon = octicons.x.toSVG({ height: 18 });
this.ignoreIcon = octicons.skip.toSVG({ height: 18 });
this.commitMessageTags = [];

ungit.config.commitMessageTags.forEach((elt) => {
let selected = ko.observable(false);
this.commitMessageTags.push({
text: elt,
selected,
toggle() {
selected(!selected());
},
});
});
}

updateNode(parentElement) {
Expand Down Expand Up @@ -265,6 +277,21 @@ class StagingViewModel extends ComponentRoot {
}
this.amend(false);
this.emptyCommit(false);
this.commitMessageTags.forEach(function (elt) {
elt.selected(false);
});
}

buildCommitMessage() {
var commitMessage = this.commitMessageTitle();
if (this.commitMessageBody()) commitMessage += '\n\n' + this.commitMessageBody();

this.commitMessageTags.forEach(function (elt) {
if (elt.selected()) {
commitMessage = elt.text + ' ' + commitMessage;
}
});
return commitMessage;
}

commit() {
Expand All @@ -274,8 +301,8 @@ class StagingViewModel extends ComponentRoot {
name: file.name(),
patchLineList: file.editState() === 'patched' ? file.patchLineList() : null,
}));
let commitMessage = this.commitMessageTitle();
if (this.commitMessageBody()) commitMessage += `\n\n${this.commitMessageBody()}`;

let commitMessage = this.buildCommitMessage();

this.server
.postPromise('/commit', {
Expand All @@ -299,8 +326,8 @@ class StagingViewModel extends ComponentRoot {
name: file.name(),
patchLineList: file.editState() === 'patched' ? file.patchLineList() : null,
}));
let commitMessage = this.commitMessageTitle();
if (this.commitMessageBody()) commitMessage += `\n\n${this.commitMessageBody()}`;

let commitMessage = this.buildCommitMessage();

this.server
.postPromise('/commit', {
Expand Down
9 changes: 9 additions & 0 deletions components/staging/staging.less
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@
}
}

.tag-button {
padding: 0;
&:active,
&:focus,
&:hover {
text-decoration: none;
}
}

.checkmark {
color: #ffffff;
display: inline-block;
Expand Down
10 changes: 9 additions & 1 deletion source/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ const defaultConfig = {

// when false, disable numstats durin status for performance. see #1193
isEnableNumStat: true,

// tags prepended to the commit message when selected (e.g. [SKIP CI])
commitMessageTags: [],
};

// Works for now but should be moved to bin/ungit
Expand Down Expand Up @@ -324,7 +327,12 @@ const argv = yargs
'isEnableNumStat',
'when false, disables numstats during git status for performance. see #1193'
)
.boolean('isEnableNumStat');
.boolean('isEnableNumStat')
.describe(
'commitMessageTags',
'tags prepended to the commit message when selected (e.g. [SKIP CI])'
)
.array('commitMessageTags');
const argvConfig = argv.argv;

// When ungit is started normally, $0 == ungit, and non-hyphenated options exists, show help and exit.
Expand Down