Skip to content

Commit

Permalink
Add option for --signoff
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmior authored and mzuehlke committed Oct 8, 2024
1 parent 3b616b4 commit bd672e3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All command line arguments for the `scala-steward` application.

```
Usage:
scala-steward --workspace <file> --repos-file <uri> [--repos-file <uri>]... [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--forge-type <forge-type>] [--forge-api-host <uri>] --forge-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-use-default-reviewers] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--gitlab-required-reviewers <integer>] [--gitlab-remove-source-branch] [--azure-repos-organization <string>] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>]... [--default-maven-repo <string>] [--refresh-backoff-period <duration>] [--exit-code-success-if-any-repo-succeeds]
scala-steward --workspace <file> --repos-file <uri> [--repos-file <uri>]... [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--signoff] [--forge-type <forge-type>] [--forge-api-host <uri>] --forge-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-use-default-reviewers] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--gitlab-required-reviewers <integer>] [--gitlab-remove-source-branch] [--azure-repos-organization <string>] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>]... [--default-maven-repo <string>] [--refresh-backoff-period <duration>] [--exit-code-success-if-any-repo-succeeds]
scala-steward validate-repo-config
Expand All @@ -26,6 +26,8 @@ Options and flags:
An executable file that returns the git credentials
--sign-commits
Whether to sign commits; default: false
--signoff
Whether to signoff commits; default: false
--forge-type <forge-type>
One of azure-repos, bitbucket, bitbucket-server, github, gitlab, gitea; default: github
--vcs-type <forge-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ object Cli {
private val signCommits: Opts[Boolean] =
flag("sign-commits", "Whether to sign commits; default: false").orFalse

private val signoff: Opts[Boolean] =
flag("signoff", "Whether to signoff commits; default: false").orFalse

private val gitCfg: Opts[GitCfg] =
(gitAuthor, gitAskPass, signCommits).mapN(GitCfg.apply)
(gitAuthor, gitAskPass, signCommits, signoff).mapN(GitCfg.apply)

private val vcsType =
option[ForgeType](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ object Config {
final case class GitCfg(
gitAuthor: Author,
gitAskPass: File,
signCommits: Boolean
signCommits: Boolean,
signoff: Boolean
)

final case class ForgeCfg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class FileGitAlg[F[_]](config: GitCfg)(implicit
override def commitAll(repo: File, message: CommitMsg): F[Commit] = {
val messages = message.paragraphs.foldMap(m => List("-m", m))
val trailers = message.trailers.foldMap { case (k, v) => List("--trailer", s"$k=$v") }
git_("commit" :: "--all" :: sign :: messages ++ trailers: _*)(repo) >>
git_("commit" :: "--all" :: sign :: signoff :: messages ++ trailers: _*)(repo) >>
latestSha1(repo, Branch.head).map(Commit.apply)
}

Expand Down Expand Up @@ -170,6 +170,9 @@ final class FileGitAlg[F[_]](config: GitCfg)(implicit

private val sign: String =
if (config.signCommits) "--gpg-sign" else "--no-gpg-sign"

private val signoff: String =
if (config.signoff) "--signoff" else "--no-signoff"
}

object FileGitAlg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ object MockState {

def gitCommit(repoDir: File, messages: String*): Cmd = {
val args =
"commit" :: "--all" :: "--no-gpg-sign" :: messages.toList.flatMap(m => List("-m", m))
"commit" :: "--all" :: "--no-gpg-sign" :: "--no-signoff" :: messages.toList.flatMap(m =>
List("-m", m)
)
git(repoDir, args: _*)
}

Expand Down

0 comments on commit bd672e3

Please sign in to comment.