Skip to content

Commit

Permalink
Merge pull request #587 from jhnsmth/topic/tiny-code-tweaks
Browse files Browse the repository at this point in the history
Tiny code tweaks
  • Loading branch information
fthomas authored Jun 18, 2019
2 parents bce2178 + f5392b3 commit 635ce02
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import caseapp._
import caseapp.core.Error.MalformedValue
import caseapp.core.argparser.{ArgParser, SimpleArgParser}
import cats.implicits._
import org.http4s.Uri
import org.http4s.{Http4sLiteralSyntax, Uri}
import org.scalasteward.core.application.Cli._
import org.scalasteward.core.util.ApplicativeThrowable

Expand All @@ -37,7 +37,7 @@ object Cli {
reposFile: String,
gitAuthorName: String,
gitAuthorEmail: String,
githubApiHost: Uri = Uri.uri("https://api.github.com"),
githubApiHost: Uri = uri"https://api.github.com",
githubLogin: String,
gitAskPass: String,
signCommits: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ object Context {
def create[F[_]: ConcurrentEffect](args: List[String]): Resource[F, StewardAlg[F]] =
for {
cliArgs_ <- Resource.liftF(new Cli[F].parseArgs(args))
config_ <- Resource.liftF(Config.create[F](cliArgs_))
client_ <- BlazeClientBuilder[F](ExecutionContext.global).resource
logger_ <- Resource.liftF(Slf4jLogger.create[F])
user_ <- Resource.liftF(config_.gitHubUser[F])
implicit0(config: Config) <- Resource.liftF(Config.create[F](cliArgs_))
implicit0(client: Client[F]) <- BlazeClientBuilder[F](ExecutionContext.global).resource
implicit0(logger: Logger[F]) <- Resource.liftF(Slf4jLogger.create[F])
implicit0(user: AuthenticatedUser) <- Resource.liftF(config.gitHubUser[F])
} yield {
implicit val client: Client[F] = client_
implicit val config: Config = config_
implicit val logger: Logger[F] = logger_
implicit val dateTimeAlg: DateTimeAlg[F] = DateTimeAlg.create[F]
implicit val fileAlg: FileAlg[F] = FileAlg.create[F]
implicit val logAlg: LogAlg[F] = new LogAlg[F]
implicit val processAlg: ProcessAlg[F] = ProcessAlg.create[F]
implicit val user: AuthenticatedUser = user_
implicit val workspaceAlg: WorkspaceAlg[F] = WorkspaceAlg.create[F]
implicit val repoConfigAlg: RepoConfigAlg[F] = new RepoConfigAlg[F]
implicit val filterAlg: FilterAlg[F] = new FilterAlg[F]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.scalasteward.core.application

import cats.implicits._
import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.application.Cli.EnvVar
import org.scalatest.{FunSuite, Matchers}

Expand Down Expand Up @@ -29,7 +29,7 @@ class CliTest extends FunSuite with Matchers {
reposFile = "b",
gitAuthorName = "Scala Steward",
gitAuthorEmail = "d",
githubApiHost = Uri.uri("http://example.com"),
githubApiHost = uri"http://example.com",
githubLogin = "e",
gitAskPass = "f",
ignoreOptsFiles = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.scalasteward.core.git

import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.vcs.data.Repo
import org.scalasteward.core.mock.MockContext._
import org.scalasteward.core.mock.MockState
Expand All @@ -11,7 +11,7 @@ class GitAlgTest extends FunSuite with Matchers {
val repoDir: String = (config.workspace / "fthomas/datapackage").toString

test("clone") {
val url = Uri.uri("https://scala-steward@github.com/fthomas/datapackage")
val url = uri"https://scala-steward@github.com/fthomas/datapackage"
val state = gitAlg.clone(repo, url).runS(MockState.empty).unsafeRunSync()

state shouldBe MockState.empty.copy(
Expand Down Expand Up @@ -64,7 +64,7 @@ class GitAlgTest extends FunSuite with Matchers {
}

test("syncFork") {
val url = Uri.uri("http://github.com/fthomas/datapackage")
val url = uri"http://github.com/fthomas/datapackage"
val defaultBranch = Branch("master")

val state = gitAlg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.scalasteward.core.github

import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.git.Branch
import org.scalasteward.core.vcs.data.{Repo, RepoOut, UserOut}
import org.scalasteward.core.mock.MockContext.{config, gitAlg, gitHubRepoAlg}
Expand All @@ -16,15 +16,15 @@ class GitHubRepoAlgTest extends FunSuite with Matchers {
"datapackage",
UserOut("fthomas"),
None,
Uri.uri("https://github.com/fthomas/datapackage"),
uri"https://github.com/fthomas/datapackage",
Branch("master")
)

val forkRepoOut = RepoOut(
"datapackage",
UserOut("scalasteward"),
Some(parentRepoOut),
Uri.uri("https://github.com/scala-steward/datapackage"),
uri"https://github.com/scala-steward/datapackage",
Branch("master")
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.scalasteward.core.github

import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.git.Branch
import org.scalasteward.core.vcs.data.Repo
import org.scalatest.{FunSuite, Matchers}

class UrlTest extends FunSuite with Matchers {
val url = new Url(Uri.uri("https://api.github.com"))
val url = new Url(uri"https://api.github.com")
import url._

val repo = Repo("fthomas", "refined")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.http4s.circe._
import org.http4s.client.Client
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.http4s.{HttpRoutes, Uri}
import org.http4s.{Http4sLiteralSyntax, HttpRoutes}
import org.scalasteward.core.git.Sha1.HexString
import org.scalasteward.core.git.{Branch, Sha1}
import org.scalasteward.core.vcs.data._
Expand Down Expand Up @@ -67,15 +67,15 @@ class Http4sGitHubApiAlgTest extends FunSuite with Matchers {
"base.g8",
UserOut("fthomas"),
None,
Uri.uri("https://github.com/fthomas/base.g8.git"),
uri"https://github.com/fthomas/base.g8.git",
Branch("master")
)

val fork = RepoOut(
"base.g8-1",
UserOut("scala-steward"),
Some(parent),
Uri.uri("https://github.com/scala-steward/base.g8-1.git"),
uri"https://github.com/scala-steward/base.g8-1.git",
Branch("master")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object MockContext {
workspace = File.temp / "ws",
reposFile = File.temp / "repos.md",
gitAuthor = Author("Bot Doe", "bot@example.org"),
gitHubApiHost = Uri.uri(""),
gitHubApiHost = Uri(),
gitHubLogin = "bot-doe",
gitAskPass = File.temp / "askpass.sh",
signCommits = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.scalasteward.core.util

import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalatest.{FunSuite, Matchers}

class uriTest extends FunSuite with Matchers {

test("withUserInfo") {
val url = Uri.uri("https://api.github.com/repos/")
val url = uri"https://api.github.com/repos/"
uri.withUserInfo.set("user:pass")(url).toString shouldBe
"https://user:pass@api.github.com/repos/"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.scalasteward.core.vcs.data

import io.circe.parser
import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.vcs.data.PullRequestState.Open
import org.scalatest.{FunSuite, Matchers}
import scala.io.Source
Expand All @@ -11,7 +11,7 @@ class PullRequestOutTest extends FunSuite with Matchers {
val expected =
List(
PullRequestOut(
Uri.unsafeFromString("https://github.com/octocat/Hello-World/pull/1347"),
uri"https://github.com/octocat/Hello-World/pull/1347",
Open,
"new-feature"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.scalasteward.core.vcs.data

import cats.effect.IO
import io.circe.parser
import org.http4s.Uri
import org.http4s.Http4sLiteralSyntax
import org.scalasteward.core.git.Branch
import org.scalatest.{FunSuite, Matchers}
import scala.io.Source
Expand All @@ -13,7 +13,7 @@ class RepoOutTest extends FunSuite with Matchers {
"base.g8",
UserOut("ChristopherDavenport"),
None,
Uri.uri("https://github.com/ChristopherDavenport/base.g8.git"),
uri"https://github.com/ChristopherDavenport/base.g8.git",
Branch("master")
)

Expand All @@ -22,7 +22,7 @@ class RepoOutTest extends FunSuite with Matchers {
"base.g8-1",
UserOut("scala-steward"),
Some(parent),
Uri.uri("https://github.com/scala-steward/base.g8-1.git"),
uri"https://github.com/scala-steward/base.g8-1.git",
Branch("master")
)

Expand Down

0 comments on commit 635ce02

Please sign in to comment.