Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a type for CodebaseName #996

Merged
merged 10 commits into from
Mar 7, 2024
Merged

Conversation

mkondratek
Copy link
Contributor

@mkondratek mkondratek commented Mar 6, 2024

Fixes #967.

Test plan

  1. tbd

@mkondratek mkondratek self-assigned this Mar 6, 2024
@@ -2,13 +2,15 @@ package com.sourcegraph.vcs

import java.net.URI

fun convertGitCloneURLToCodebaseNameOrError(cloneURL: String): String {
data class CodebaseName(val value: String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value always some kind of the url?
If yes, maybe we can make the name more descriptive?
If no, maybe it warrants a comment what value we can expect there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CodebaseName is the description here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codebase name does not suggest url-like-string at all to me.
And it's not defined anywhere what it really means.
Anyway, it's just my point of view, there is nothing wrong with the code per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codebase name does not suggest url-like-string at all to me.

tbh I'd say that's a good sign - it will be harder to confuse it with URL 😅

@@ -94,7 +93,9 @@ class AddRepositoryDialog(
}

override fun doOKAction() {
addAction(repoUrlInputField.text.lowercase())
runCatching { convertGitCloneURLToCodebaseNameOrError(repoUrlInputField.text.lowercase()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move that conversion to lowercase inside convertGitCloneURLToCodebaseNameOrError?
That way we will never miss it... as we do now in case of the migration?

@@ -105,6 +109,20 @@ class SettingsMigration : Activity {
}
}

private fun migrateUrlsToCodebaseNames(project: Project) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for that.
Especially considering those cases:

  • previously added codebase name without http://
  • previously added codebase name with upercase address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

it.isEnabled = true
it.remoteRepositories =
mutableListOf(
RemoteRepositoryState().also {
Copy link
Contributor

@pkukielka pkukielka Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change one of those to show uppercase -> lowercase conversion?
Ideally if that will cause repo to be duplicated it should remove the duplication as well.

Copy link
Contributor

@pkukielka pkukielka Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you could add different enabled states to prove they are preserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@pkukielka pkukielka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkondratek mkondratek merged commit f974182 into main Mar 7, 2024
5 checks passed
@mkondratek mkondratek deleted the mkondratek/fix/codebaseName branch March 7, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JetBrains: Unable to remove remote repo for one specific project.
2 participants