-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ali Caglayan <alizter@gmail.com>
- Loading branch information
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
open Stdune | ||
module Console = Dune_console | ||
|
||
(** This script generates a changelog entry for a PR. It asks the user for | ||
information about the pull request and then generates a file in the | ||
[output_directory]. *) | ||
|
||
let output_directory = | ||
Path.source (Path.Source.of_string "doc/changes/unreleased") | ||
|
||
let () = | ||
Console.printf "Hello, let's create a changelog entry!"; | ||
Console.printf "What is the change about?"; | ||
let description = read_line () in | ||
Console.printf "PR number? (Leave blank if you don't know)"; | ||
let pr_number = | ||
match read_line () with | ||
| "" -> "????" | ||
| s -> s | ||
in | ||
Console.printf "What is your username?"; | ||
let username = read_line () in | ||
Console.printf "Which issue numbers does this change fix?"; | ||
let issues = | ||
match read_line () with | ||
| "" -> "" | ||
| s -> | ||
String.split ~on:' ' s | ||
|> List.map ~f:(fun s -> "#" ^ s) | ||
|> String.enumerate_and | ||
|> fun x -> ", fixes " ^ x | ||
in | ||
let pp = | ||
Pp.concat | ||
[ Pp.verbatim "- " | ||
; Pp.box | ||
(Pp.textf "%s (#%s%s, @%s)" description pr_number issues username) | ||
; Pp.newline | ||
] | ||
in | ||
let entry_file = | ||
Path.append_source output_directory | ||
(Path.Source.of_string (pr_number ^ "_" ^ username)) | ||
in | ||
Path.mkdir_p output_directory; | ||
Io.write_lines entry_file [ Format.asprintf "%a" Pp.to_fmt pp ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Testing the changelog adding script | ||
|
||
$ cat > user_response << EOF | ||
> Changelog description that is long enough to be wrapped to the next line | ||
> 1234 | ||
> SomeGithubUser | ||
> 123 456 789 | ||
> EOF | ||
|
||
$ ./add.exe < user_response | ||
Hello, let's create a changelog entry! | ||
What is the change about? | ||
PR number? (Leave blank if you don't know) | ||
What is your username? | ||
Which issue numbers does this change fix? | ||
|
||
$ ls doc/changes/unreleased | ||
1234_SomeGithubUser | ||
$ cat doc/changes/unreleased/* | ||
- Changelog description that is long enough to be wrapped to the next line | ||
(#1234, fixes #123, #456 and #789, @SomeGithubUser) | ||
|
||
|
||
Testing some edge cases | ||
|
||
$ cat > user_response << EOF | ||
> Changelog description that is long enough to be wrapped to the next line. \ | ||
> This one takes teh cake for being especially long. | ||
> | ||
> AnotherUser | ||
> | ||
> EOF | ||
|
||
$ ./add.exe < user_response | ||
Hello, let's create a changelog entry! | ||
What is the change about? | ||
PR number? (Leave blank if you don't know) | ||
What is your username? | ||
Which issue numbers does this change fix? | ||
|
||
$ ls doc/changes/unreleased | ||
1234_SomeGithubUser | ||
????_AnotherUser | ||
$ cat doc/changes/unreleased/* | ||
- Changelog description that is long enough to be wrapped to the next line | ||
(#1234, fixes #123, #456 and #789, @SomeGithubUser) | ||
|
||
- Changelog description that is long enough to be wrapped to the next line. | ||
This one takes teh cake for being especially long. (#????, @AnotherUser) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(executable | ||
(name add) | ||
(libraries stdune pp dune_console)) | ||
|
||
(cram | ||
(deps add.exe)) | ||
|
||
(rule | ||
(alias compile-changelog) | ||
(deps | ||
(glob_files unreleased/*)) | ||
(action | ||
(with-stdout-to | ||
changes-new.md | ||
(progn | ||
(echo "Unreleased\n") | ||
(echo "----------\n") | ||
(echo "\n") | ||
(cat %{deps}) | ||
(cat ../../CHANGES.md))))) | ||
|
||
(rule | ||
(alias compile-changelog) | ||
(action | ||
(diff ../../CHANGES.md changes-new.md))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters