Skip to content

Commit

Permalink
style(conventional): rename module
Browse files Browse the repository at this point in the history
  • Loading branch information
pedraal committed Aug 17, 2024
1 parent ed94245 commit 812a8e1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/releam.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gleam/io
import gleam/list
import gleam/result
import gleam/string
import releam/conventional_commit.{
import releam/conventional_attributes.{
type ConventionalAttributes, type ConventionalCommitParseError,
InvalidCommitDefinition,
}
Expand Down Expand Up @@ -73,6 +73,7 @@ pub fn parse_commit(raw: String) {
|> string.split("\n")
|> list.map(string.trim(_))
|> list.filter(fn(str) { str != "" })
|> io.debug
case commit_props {
// [hash, author, date, message, ..bodies] -> {
// let conventional_attributes = parse_conventional_attributes(message)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gleam/option.{None, Some}
import gleeunit
import gleeunit/should
import releam/conventional_commit.{
import releam/conventional_attributes.{
Build, Chore, Ci, ConventionalAttributes, ConventionalDefinition,
ConventionalOptionalSections, Custom, Docs, Feat, Fix, InvalidCommitDefinition,
InvalidConventionalFooter, Perf, Refactor, Revert, Style, Test,
Expand All @@ -13,7 +13,7 @@ pub fn main() {

pub fn parse_attributes_simple_with_breaking_test() {
"feat!: send an email to the customer when a product is shipped"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Feat,
Expand All @@ -28,7 +28,7 @@ pub fn parse_attributes_simple_with_breaking_test() {

pub fn parse_attributes_simple_with_scope_test() {
"chore(deps): bump versions\n"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Chore,
Expand All @@ -43,7 +43,7 @@ pub fn parse_attributes_simple_with_scope_test() {

pub fn parse_attributes_simple_with_scope_and_breaking_test() {
"chore(deps)!: bump versions\n"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Chore,
Expand All @@ -60,7 +60,7 @@ pub fn parse_attributes_with_breaking_and_breaking_footer_test() {
"feat(api)!: drop support for uids
BREAKING CHANGE: drop support for queries using uids"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Feat,
Expand All @@ -82,7 +82,7 @@ pub fn parse_attributes_with_bodies_test() {
Remove timeouts which were used to mitigate the racing issue but are
obsolete now.
"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Fix,
Expand All @@ -109,7 +109,7 @@ pub fn parse_attributes_with_body_and_footers_test() {
Reviewed-by: Z
Refs: #123"
|> conventional_commit.parse_attributes
|> conventional_attributes.parse_attributes
|> should.equal(
Ok(ConventionalAttributes(
Fix,
Expand All @@ -126,7 +126,7 @@ pub fn parse_attributes_with_body_and_footers_test() {
}

pub fn parse_definition_test() {
conventional_commit.parse_definition("feat: lorem ipsum")
conventional_attributes.parse_definition("feat: lorem ipsum")
|> should.equal(
Ok(ConventionalDefinition(
commit_type: Feat,
Expand All @@ -136,7 +136,7 @@ pub fn parse_definition_test() {
)),
)

conventional_commit.parse_definition("feat(api): lorem ipsum")
conventional_attributes.parse_definition("feat(api): lorem ipsum")
|> should.equal(
Ok(ConventionalDefinition(
commit_type: Feat,
Expand All @@ -146,7 +146,7 @@ pub fn parse_definition_test() {
)),
)

conventional_commit.parse_definition("feat(api)!: lorem ipsum")
conventional_attributes.parse_definition("feat(api)!: lorem ipsum")
|> should.equal(
Ok(ConventionalDefinition(
commit_type: Feat,
Expand All @@ -156,7 +156,7 @@ pub fn parse_definition_test() {
)),
)

conventional_commit.parse_definition("feat!: lorem ipsum")
conventional_attributes.parse_definition("feat!: lorem ipsum")
|> should.equal(
Ok(ConventionalDefinition(
commit_type: Feat,
Expand All @@ -166,7 +166,7 @@ pub fn parse_definition_test() {
)),
)

conventional_commit.parse_definition("foo: lorem ipsum")
conventional_attributes.parse_definition("foo: lorem ipsum")
|> should.equal(
Ok(ConventionalDefinition(
commit_type: Custom("foo"),
Expand All @@ -176,7 +176,7 @@ pub fn parse_definition_test() {
)),
)

conventional_commit.parse_definition("lorem ipsum")
conventional_attributes.parse_definition("lorem ipsum")
|> should.equal(Error(InvalidCommitDefinition))
}

Expand All @@ -188,7 +188,7 @@ pub fn parse_optional_sections_test() {
Refs: #123
BREAKING CHANGE: drop json support",
]
|> conventional_commit.parse_optional_sections
|> conventional_attributes.parse_optional_sections
|> should.equal(ConventionalOptionalSections(
body: ["foo bar baz", "lorem ipsum"],
footer: [
Expand All @@ -202,7 +202,7 @@ pub fn parse_optional_sections_test() {

pub fn parse_optional_sections_with_invalid_footer_test() {
["foo bar", "lorem ipsum", "Reviewed by: Z"]
|> conventional_commit.parse_optional_sections
|> conventional_attributes.parse_optional_sections
|> should.equal(ConventionalOptionalSections(
body: ["foo bar", "lorem ipsum", "Reviewed by: Z"],
footer: [],
Expand All @@ -213,65 +213,65 @@ pub fn parse_optional_sections_with_invalid_footer_test() {
pub fn parse_footer_test() {
"Reviewed-by: Z
Refs: #123"
|> conventional_commit.parse_footer
|> conventional_attributes.parse_footer
|> should.equal(Ok([#("Reviewed-by", "Z"), #("Refs", "#123")]))
}

pub fn parse_footer_with_breaking_change_test() {
"Reviewed-by: Z
BREAKING CHANGE: drop json support"
|> conventional_commit.parse_footer
|> conventional_attributes.parse_footer
|> should.equal(
Ok([#("Reviewed-by", "Z"), #("BREAKING CHANGE", "drop json support")]),
)
}

pub fn parse_footer_with_invalid_test() {
"Reviewed by: Z"
|> conventional_commit.parse_footer
|> conventional_attributes.parse_footer
|> should.equal(Error(InvalidConventionalFooter))
}

pub fn parse_commit_type_test() {
conventional_commit.parse_commit_type("feat")
conventional_attributes.parse_commit_type("feat")
|> should.equal(Feat)

conventional_commit.parse_commit_type("fix")
conventional_attributes.parse_commit_type("fix")
|> should.equal(Fix)

conventional_commit.parse_commit_type("docs")
conventional_attributes.parse_commit_type("docs")
|> should.equal(Docs)

conventional_commit.parse_commit_type("style")
conventional_attributes.parse_commit_type("style")
|> should.equal(Style)

conventional_commit.parse_commit_type("refactor")
conventional_attributes.parse_commit_type("refactor")
|> should.equal(Refactor)

conventional_commit.parse_commit_type("refacto")
conventional_attributes.parse_commit_type("refacto")
|> should.equal(Refactor)

conventional_commit.parse_commit_type("perf")
conventional_attributes.parse_commit_type("perf")
|> should.equal(Perf)

conventional_commit.parse_commit_type("test")
conventional_attributes.parse_commit_type("test")
|> should.equal(Test)

conventional_commit.parse_commit_type("tests")
conventional_attributes.parse_commit_type("tests")
|> should.equal(Test)

conventional_commit.parse_commit_type("build")
conventional_attributes.parse_commit_type("build")
|> should.equal(Build)

conventional_commit.parse_commit_type("ci")
conventional_attributes.parse_commit_type("ci")
|> should.equal(Ci)

conventional_commit.parse_commit_type("chore")
conventional_attributes.parse_commit_type("chore")
|> should.equal(Chore)

conventional_commit.parse_commit_type("revert")
conventional_attributes.parse_commit_type("revert")
|> should.equal(Revert)

conventional_commit.parse_commit_type("whatever")
conventional_attributes.parse_commit_type("whatever")
|> should.equal(Custom("whatever"))
}

0 comments on commit 812a8e1

Please sign in to comment.