Skip to content

Commit

Permalink
Fix Select All for Mercurial and octohorpe
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed May 1, 2021
1 parent d1c2f0d commit 862b3a2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
19 changes: 10 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
4. [x] Use --file-forwarding and remove filesystem permissions
5. [x] Launch and show instructions
6. [x] bug: Cancel / esc does not abort rebase or git commit amend
7. [ ] bug: select all selects mercurial comments
8. [ ] length hint should be a setting
9. [ ] Commit button should say "Save" if type isn't recognize (editing a regular file) and set title to filename
10. [ ] conventional commit? https://www.conventionalcommits.org/en/v1.0.0/
11. [ ] GTK 4 - depends on https://gitlab.gnome.org/GNOME/gspell/-/issues/17
7. [x] bug: select all selects mercurial comments
8. [x] bug: select all stops at # instead of comment
9. [ ] length hint should be a setting
10. [ ] Commit button should say "Save" if type isn't recognize (editing a regular file) and set title to filename and disable cancel
11. [ ] conventional commit? https://www.conventionalcommits.org/en/v1.0.0/
12. [ ] GTK 4 - depends on https://gitlab.gnome.org/GNOME/gspell/-/issues/17
1. [ ] undo/redo support depends on GTK 4 where GTKTextView natively supports it
2. [ ] emoji autocomplete - gitmoji shortcuts? https://gitlab.gnome.org/GNOME/gtk/-/issues/86
12. [ ] https://chris.beams.io/posts/git-commit/#seven-rules
13. [ ] Usage (README.md) in instructions? userdoc?
14. [ ] preview commit from welcome?
15. [ ] screenshots welcome window?
13. [ ] https://chris.beams.io/posts/git-commit/#seven-rules
14. [ ] Usage (README.md) in instructions? userdoc?
15. [ ] preview commit from welcome?
16. [ ] screenshots welcome window?
11 changes: 7 additions & 4 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ function openEditor({ file, application }) {
print(`Warning: unknown commit type encountered in: ${filePath}`);
}

const { body: commitBody, comment: commitComment, detail } = parse(
commitMessage,
type,
);
const {
body: commitBody,
comment: commitComment,
detail,
comment_separator,
} = parse(commitMessage, type);

const commitCommentLines = commitComment.split("\n");
const numberOfLinesInCommitComment = commitCommentLines.length;
Expand All @@ -114,6 +116,7 @@ function openEditor({ file, application }) {
application,
file,
numberOfLinesInCommitComment,
comment_separator,
});
// Add the dialog to the application as its main window.
application.add_window(window);
Expand Down
3 changes: 2 additions & 1 deletion src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function Editor({
builder,
commitButton,
numberOfLinesInCommitComment,
comment_separator,
}) {
let lastActionWasSelectAll;

Expand Down Expand Up @@ -186,7 +187,7 @@ export default function Editor({
// Assumption: that the person has not added any comments
// to their commit message themselves. But, I mean, come on!
// buffer.place_cursor(buffer.get_start_iter())
const mainCommitMessage = buffer.text.split("#")[0];
const mainCommitMessage = buffer.text.split(comment_separator)[0];
const selectStartIterator = buffer.get_start_iter();
const selectEndIterator = buffer.get_iter_at_offset(
unicodeLength(mainCommitMessage),
Expand Down
2 changes: 1 addition & 1 deletion src/scm.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function parse(commit, type) {
detail = `${_detailChunks[1]}${_detailChunks[3]}`;
}

return { body, comment, detail };
return { body, comment, detail, comment_prefix, comment_separator };
}

export function getType(filename) {
Expand Down
2 changes: 2 additions & 0 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function Window({
application,
file,
numberOfLinesInCommitComment,
comment_separator,
}) {
const builder = Gtk.Builder.new_from_file(relativePath("./window.ui"));

Expand Down Expand Up @@ -43,6 +44,7 @@ export default function Window({
builder,
commitButton,
numberOfLinesInCommitComment,
comment_separator,
});

window.connect("style-updated", () => {
Expand Down
11 changes: 11 additions & 0 deletions test/scm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ is(
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.`,
);
is(parse(readTest("addp-hunk-edit.diff"), "add -p").comment_prefix, "#");
is(parse(readTest("addp-hunk-edit.diff"), "add -p").comment_separator, "\n#");

is(parse(readTest("MERGE_MSG"), "merge").body, `Merge branch 'test'`);
is(parse(readTest("MERGE_MSG"), "merge").detail, `branch test`);
Expand Down Expand Up @@ -200,6 +202,15 @@ HG: branch 'default'
HG: added foobar
`,
);
is(
parse(readTest("hg-editor-without_body.commit.hg.txt"), "hg").comment_prefix,
"HG:",
);
is(
parse(readTest("hg-editor-without_body.commit.hg.txt"), "hg")
.comment_separator,
"\nHG:",
);

is(
parse(readTest("hg-editor-with_body.commit.hg.txt"), "hg").body,
Expand Down

0 comments on commit 862b3a2

Please sign in to comment.