Skip to content

Commit

Permalink
Rename code-hosting-origin-hostname to hosting-origin-hostname (#3053)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo committed Feb 2, 2024
1 parent 3f663e4 commit eeea0cc
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 83 deletions.
4 changes: 2 additions & 2 deletions features/config/setup/change_git_metadata.feature
Expand Up @@ -40,7 +40,7 @@ Feature: change existing information in Git metadata
| git config --global alias.sync "town sync" |
| git config git-town.github-token 123456 |
| git config git-town.code-hosting-platform github |
| git config git-town.code-hosting-origin-hostname code |
| git config git-town.hosting-origin-hostname code |
And global Git setting "alias.append" is now "town append"
And global Git setting "alias.diff-parent" is now "town diff-parent"
And global Git setting "alias.hack" is now "town hack"
Expand All @@ -56,7 +56,7 @@ Feature: change existing information in Git metadata
And the perennial branches are now "production"
And local Git Town setting "code-hosting-platform" is now "github"
And local Git Town setting "github-token" is now "123456"
And local Git Town setting "code-hosting-origin-hostname" is now "code"
And local Git Town setting "hosting-origin-hostname" is now "code"
And local Git Town setting "sync-feature-strategy" is now "rebase"
And local Git Town setting "sync-perennial-strategy" is now "merge"
And local Git Town setting "sync-upstream" is now "false"
Expand Down
2 changes: 1 addition & 1 deletion features/config/setup/migrate_git_to_file.feature
Expand Up @@ -54,7 +54,7 @@ Feature: migrate existing configuration in Git metadata to a config file
And there are now no perennial branches
And local Git Town setting "code-hosting-platform" now doesn't exist
And local Git Town setting "github-token" is now "123456"
And local Git Town setting "code-hosting-origin-hostname" now doesn't exist
And local Git Town setting "hosting-origin-hostname" now doesn't exist
And local Git Town setting "sync-feature-strategy" now doesn't exist
And local Git Town setting "sync-perennial-strategy" now doesn't exist
And local Git Town setting "sync-upstream" now doesn't exist
Expand Down
32 changes: 16 additions & 16 deletions features/config/setup/remove_git_metadata.feature
Expand Up @@ -18,7 +18,7 @@ Feature: remove existing configuration in Git metadata
And local Git Town setting "code-hosting-platform" is "github"
And local Git Town setting "push-new-branches" is "false"
And local Git Town setting "push-hook" is "false"
And local Git Town setting "code-hosting-origin-hostname" is "code"
And local Git Town setting "hosting-origin-hostname" is "code"
And local Git Town setting "sync-feature-strategy" is "rebase"
And local Git Town setting "sync-perennial-strategy" is "rebase"
And local Git Town setting "sync-upstream" is "true"
Expand All @@ -45,20 +45,20 @@ Feature: remove existing configuration in Git metadata

Scenario: result
Then it runs the commands
| COMMAND |
| git config --global --unset alias.append |
| git config --global --unset alias.diff-parent |
| git config --global --unset alias.hack |
| git config --global --unset alias.kill |
| git config --global --unset alias.prepend |
| git config --global --unset alias.propose |
| git config --global --unset alias.rename-branch |
| git config --global --unset alias.repo |
| git config --global --unset alias.set-parent |
| git config --global --unset alias.ship |
| git config --global --unset alias.sync |
| git config --unset git-town.code-hosting-platform |
| git config --unset git-town.code-hosting-origin-hostname |
| COMMAND |
| git config --global --unset alias.append |
| git config --global --unset alias.diff-parent |
| git config --global --unset alias.hack |
| git config --global --unset alias.kill |
| git config --global --unset alias.prepend |
| git config --global --unset alias.propose |
| git config --global --unset alias.rename-branch |
| git config --global --unset alias.repo |
| git config --global --unset alias.set-parent |
| git config --global --unset alias.ship |
| git config --global --unset alias.sync |
| git config --unset git-town.code-hosting-platform |
| git config --unset git-town.hosting-origin-hostname |
And global Git setting "alias.append" now doesn't exist
And global Git setting "alias.diff-parent" now doesn't exist
And global Git setting "alias.hack" now doesn't exist
Expand All @@ -74,7 +74,7 @@ Feature: remove existing configuration in Git metadata
And the perennial branches are now "production"
And local Git Town setting "code-hosting-platform" now doesn't exist
And local Git Town setting "github-token" now doesn't exist
And local Git Town setting "code-hosting-origin-hostname" now doesn't exist
And local Git Town setting "hosting-origin-hostname" now doesn't exist
And local Git Town setting "sync-feature-strategy" is now "merge"
And local Git Town setting "sync-perennial-strategy" is now "merge"
And local Git Town setting "sync-upstream" is now "false"
Expand Down
17 changes: 17 additions & 0 deletions features/config/upgrade/code_hosting_origin_hostname.feature
@@ -0,0 +1,17 @@
Feature: automatically upgrade outdated configuration

Scenario Outline:
Given <LOCATION> Git Town setting "code-hosting-origin-hostname" is "git.acme.com"
When I run "git-town config"
Then it prints:
"""
I found the deprecated <LOCATION> setting "git-town.code-hosting-origin-hostname".
I am upgrading this setting to the new format "git-town.hosting-origin-hostname".
"""
And <LOCATION> Git Town setting "hosting-origin-hostname" is now "git.acme.com"
And <LOCATION> Git Town setting "code-hosting-origin-hostname" now doesn't exist

Examples:
| LOCATION |
| local |
| global |
2 changes: 1 addition & 1 deletion features/propose/features/ssh_identity.feature
Expand Up @@ -4,7 +4,7 @@ Feature: use a SSH identity
Scenario Outline: ssh identity
And tool "open" is installed
And the origin is "git@my-ssh-identity:git-town/git-town.git"
And Git Town setting "code-hosting-origin-hostname" is "<ORIGIN_HOSTNAME>"
And Git Town setting "hosting-origin-hostname" is "<ORIGIN_HOSTNAME>"
And the current branch is a feature branch "feature"
When I run "git-town propose"
Then "open" launches a new proposal with this url in my browser:
Expand Down
2 changes: 1 addition & 1 deletion features/repo/features/ssh_identity.feature
Expand Up @@ -4,7 +4,7 @@ Feature: use an SSH identity
Scenario Outline:
Given tool "open" is installed
And the origin is "git@my-ssh-identity:git-town/git-town.git"
And Git Town setting "code-hosting-origin-hostname" is "<ORIGIN_HOSTNAME>"
And Git Town setting "hosting-origin-hostname" is "<ORIGIN_HOSTNAME>"
When I run "git-town repo"
Then "open" launches a new proposal with this url in my browser:
"""
Expand Down
1 change: 1 addition & 0 deletions src/config/gitconfig/access.go
Expand Up @@ -100,6 +100,7 @@ func AddKeyToPartialConfig(key Key, value string, config *configdomain.PartialCo
case KeySyncUpstream:
config.SyncUpstream, err = configdomain.ParseSyncUpstreamRef(value, KeySyncUpstream.String())
case KeyDeprecatedCodeHostingDriver,
KeyDeprecatedCodeHostingOriginHostname,
KeyDeprecatedMainBranchName,
KeyDeprecatedNewBranchPushFlag,
KeyDeprecatedPerennialBranchNames,
Expand Down
93 changes: 48 additions & 45 deletions src/config/gitconfig/key.go
Expand Up @@ -28,49 +28,51 @@ func (self *Key) UnmarshalJSON(b []byte) error {
}

const (
KeyAliasAppend = Key("alias.append")
KeyAliasDiffParent = Key("alias.diff-parent")
KeyAliasHack = Key("alias.hack")
KeyAliasKill = Key("alias.kill")
KeyAliasPrepend = Key("alias.prepend")
KeyAliasPropose = Key("alias.propose")
KeyAliasRenameBranch = Key("alias.rename-branch")
KeyAliasRepo = Key("alias.repo")
KeyAliasSetParent = Key("alias.set-parent")
KeyAliasShip = Key("alias.ship")
KeyAliasSync = Key("alias.sync")
KeyDeprecatedCodeHostingDriver = Key("git-town.code-hosting-driver")
KeyDeprecatedMainBranchName = Key("git-town.main-branch-name")
KeyDeprecatedNewBranchPushFlag = Key("git-town.new-branch-push-flag")
KeyDeprecatedPerennialBranchNames = Key("git-town.perennial-branch-names")
KeyDeprecatedPullBranchStrategy = Key("git-town.pull-branch-strategy")
KeyDeprecatedPushVerify = Key("git-town.push-verify")
KeyDeprecatedShipDeleteRemoteBranch = Key("git-town.ship-delete-remote-branch")
KeyDeprecatedSyncStrategy = Key("git-town.sync-strategy")
KeyGiteaToken = Key("git-town.gitea-token")
KeyGithubToken = Key("git-town.github-token")
KeyGitlabToken = Key("git-town.gitlab-token")
KeyHostingOriginHostname = Key("git-town.code-hosting-origin-hostname")
KeyHostingPlatform = Key("git-town.code-hosting-platform")
KeyMainBranch = Key("git-town.main-branch")
KeyOffline = Key("git-town.offline")
KeyPerennialBranches = Key("git-town.perennial-branches")
KeyPushHook = Key("git-town.push-hook")
KeyPushNewBranches = Key("git-town.push-new-branches")
KeyShipDeleteTrackingBranch = Key("git-town.ship-delete-tracking-branch")
KeySyncBeforeShip = Key("git-town.sync-before-ship")
KeySyncFeatureStrategy = Key("git-town.sync-feature-strategy")
KeySyncPerennialStrategy = Key("git-town.sync-perennial-strategy")
KeySyncStrategy = Key("git-town.sync-strategy")
KeySyncUpstream = Key("git-town.sync-upstream")
KeyGitUserEmail = Key("user.email")
KeyGitUserName = Key("user.name")
KeyAliasAppend = Key("alias.append")
KeyAliasDiffParent = Key("alias.diff-parent")
KeyAliasHack = Key("alias.hack")
KeyAliasKill = Key("alias.kill")
KeyAliasPrepend = Key("alias.prepend")
KeyAliasPropose = Key("alias.propose")
KeyAliasRenameBranch = Key("alias.rename-branch")
KeyAliasRepo = Key("alias.repo")
KeyAliasSetParent = Key("alias.set-parent")
KeyAliasShip = Key("alias.ship")
KeyAliasSync = Key("alias.sync")
KeyDeprecatedCodeHostingDriver = Key("git-town.code-hosting-driver")
KeyDeprecatedCodeHostingOriginHostname = Key("git-town.code-hosting-origin-hostname")
KeyDeprecatedMainBranchName = Key("git-town.main-branch-name")
KeyDeprecatedNewBranchPushFlag = Key("git-town.new-branch-push-flag")
KeyDeprecatedPerennialBranchNames = Key("git-town.perennial-branch-names")
KeyDeprecatedPullBranchStrategy = Key("git-town.pull-branch-strategy")
KeyDeprecatedPushVerify = Key("git-town.push-verify")
KeyDeprecatedShipDeleteRemoteBranch = Key("git-town.ship-delete-remote-branch")
KeyDeprecatedSyncStrategy = Key("git-town.sync-strategy")
KeyGiteaToken = Key("git-town.gitea-token")
KeyGithubToken = Key("git-town.github-token")
KeyGitlabToken = Key("git-town.gitlab-token")
KeyHostingOriginHostname = Key("git-town.hosting-origin-hostname")
KeyHostingPlatform = Key("git-town.code-hosting-platform")
KeyMainBranch = Key("git-town.main-branch")
KeyOffline = Key("git-town.offline")
KeyPerennialBranches = Key("git-town.perennial-branches")
KeyPushHook = Key("git-town.push-hook")
KeyPushNewBranches = Key("git-town.push-new-branches")
KeyShipDeleteTrackingBranch = Key("git-town.ship-delete-tracking-branch")
KeySyncBeforeShip = Key("git-town.sync-before-ship")
KeySyncFeatureStrategy = Key("git-town.sync-feature-strategy")
KeySyncPerennialStrategy = Key("git-town.sync-perennial-strategy")
KeySyncStrategy = Key("git-town.sync-strategy")
KeySyncUpstream = Key("git-town.sync-upstream")
KeyGitUserEmail = Key("user.email")
KeyGitUserName = Key("user.name")
)

var keys = []Key{ //nolint:gochecknoglobals
KeyHostingOriginHostname,
KeyHostingPlatform,
KeyDeprecatedCodeHostingDriver,
KeyDeprecatedCodeHostingOriginHostname,
KeyDeprecatedMainBranchName,
KeyDeprecatedNewBranchPushFlag,
KeyDeprecatedPerennialBranchNames,
Expand Down Expand Up @@ -166,12 +168,13 @@ func parseLineageKey(key string) *Key {

// DeprecatedKeys defines the up-to-date counterparts to deprecated configuration settings.
var DeprecatedKeys = map[Key]Key{ //nolint:gochecknoglobals
KeyDeprecatedCodeHostingDriver: KeyHostingPlatform,
KeyDeprecatedMainBranchName: KeyMainBranch,
KeyDeprecatedNewBranchPushFlag: KeyPushNewBranches,
KeyDeprecatedPerennialBranchNames: KeyPerennialBranches,
KeyDeprecatedPullBranchStrategy: KeySyncPerennialStrategy,
KeyDeprecatedPushVerify: KeyPushHook,
KeyDeprecatedShipDeleteRemoteBranch: KeyShipDeleteTrackingBranch,
KeyDeprecatedSyncStrategy: KeySyncFeatureStrategy,
KeyDeprecatedCodeHostingDriver: KeyHostingPlatform,
KeyDeprecatedCodeHostingOriginHostname: KeyHostingOriginHostname,
KeyDeprecatedMainBranchName: KeyMainBranch,
KeyDeprecatedNewBranchPushFlag: KeyPushNewBranches,
KeyDeprecatedPerennialBranchNames: KeyPerennialBranches,
KeyDeprecatedPullBranchStrategy: KeySyncPerennialStrategy,
KeyDeprecatedPushVerify: KeyPushHook,
KeyDeprecatedShipDeleteRemoteBranch: KeyShipDeleteTrackingBranch,
KeyDeprecatedSyncStrategy: KeySyncFeatureStrategy,
}
32 changes: 24 additions & 8 deletions test/cucumber/steps.go
Expand Up @@ -324,6 +324,14 @@ func Steps(suite *godog.Suite, state *ScenarioState) {
return nil
})

suite.Step(`^global Git Town setting "hosting-origin-hostname" is now "([^"]*)"$`, func(want string) error {
have := state.fixture.DevRepo.Config.GlobalGitConfig.HostingOriginHostname
if have.String() != want {
return fmt.Errorf(`expected global setting "hosting-origin-hostname" to be %q, but was %q`, want, *have)
}
return nil
})

suite.Step(`^global Git Town setting "main-branch" is now "([^"]*)"$`, func(wantStr string) error {
have := state.fixture.DevRepo.Config.GlobalGitConfig.MainBranch
want := gitdomain.LocalBranchName(wantStr)
Expand Down Expand Up @@ -666,14 +674,6 @@ func Steps(suite *godog.Suite, state *ScenarioState) {
return state.fixture.DevRepo.Config.GitConfig.SetLocalConfigValue(*configKey, value)
})

suite.Step(`^local Git Town setting "code-hosting-origin-hostname" is now "([^"]*)"$`, func(want string) error {
have := state.fixture.DevRepo.Config.LocalGitConfig.HostingOriginHostname
if have.String() != want {
return fmt.Errorf(`expected local setting "code-hosting-origin-hostname" to be %q, but was %q`, want, *have)
}
return nil
})

suite.Step(`^local Git Town setting "code-hosting-origin-hostname" now doesn't exist$`, func() error {
have := state.fixture.DevRepo.Config.LocalGitConfig.HostingOriginHostname
if have == nil {
Expand Down Expand Up @@ -733,6 +733,22 @@ func Steps(suite *godog.Suite, state *ScenarioState) {
return nil
})

suite.Step(`^local Git Town setting "hosting-origin-hostname" is now "([^"]*)"$`, func(want string) error {
have := state.fixture.DevRepo.Config.LocalGitConfig.HostingOriginHostname
if have.String() != want {
return fmt.Errorf(`expected local setting "hosting-origin-hostname" to be %q, but was %q`, want, *have)
}
return nil
})

suite.Step(`^local Git Town setting "hosting-origin-hostname" now doesn't exist$`, func() error {
have := state.fixture.DevRepo.Config.LocalGitConfig.HostingOriginHostname
if have == nil {
return nil
}
return fmt.Errorf(`unexpected local setting "hosting-origin-hostname" with value %q`, *have)
})

suite.Step(`^local Git Town setting "main-branch" is now "([^"]*)"$`, func(wantStr string) error {
have := state.fixture.DevRepo.Config.LocalGitConfig.MainBranch
want := gitdomain.NewLocalBranchName(wantStr)
Expand Down
2 changes: 1 addition & 1 deletion website/src/SUMMARY.md
Expand Up @@ -34,7 +34,7 @@
- [offline](commands/config-offline.md)
- [Preferences](preferences.md)
- [code-hosting-platform](preferences/code-hosting-platform.md)
- [code-hosting-origin-hostname](preferences/code-hosting-origin-hostname.md)
- [hosting-origin-hostname](preferences/hosting-origin-hostname.md)
- [github-token](preferences/github-token.md)
- [gitlab-token](preferences/gitlab-token.md)
- [main-branch](preferences/main-branch.md)
Expand Down
3 changes: 1 addition & 2 deletions website/src/commands/propose.md
Expand Up @@ -19,5 +19,4 @@ You can configure the hosting platform type with the
[code-hosting-platform](../preferences/code-hosting-platform.md) setting.

When using SSH identities, this command uses the hostname in the
[code-hosting-origin-hostname](../preferences/code-hosting-origin-hostname.md)
setting.
[hosting-origin-hostname](../preferences/hosting-origin-hostname.md) setting.
3 changes: 1 addition & 2 deletions website/src/commands/repo.md
Expand Up @@ -11,6 +11,5 @@ Git Town automatically identifies the hosting platform type through the `origin`
remote. You can override the type of hosting server with the
[code-hosting-platform](../preferences/code-hosting-platform.md) setting.

Set the
[code-hosting-origin-hostname](../preferences/code-hosting-origin-hostname.md)
Set the [hosting-origin-hostname](../preferences/hosting-origin-hostname.md)
setting to tell Git Town about the hostname when using ssh identities.
2 changes: 1 addition & 1 deletion website/src/preferences.md
Expand Up @@ -3,7 +3,7 @@
Git Town uses these configuration settings:

- [code-hosting-platform](preferences/code-hosting-platform.md)
- [code-hosting-origin-hostname](preferences/code-hosting-origin-hostname.md)
- [hosting-origin-hostname](preferences/hosting-origin-hostname.md)
- [github-token](preferences/github-token.md)
- [gitlab-token](preferences/gitlab-token.md)
- [main-branch](preferences/main-branch.md)
Expand Down
@@ -1,14 +1,14 @@
# code-hosting-origin-hostname
# hosting-origin-hostname

```
git-town.code-hosting-origin-hostname=<hostname>
git-town.hosting-origin-hostname=<hostname>
```

When using SSH identities, you can use this configuration setting to define the
hostname of your source code repository by running:

```
git config [--global] git-town.code-hosting-origin-hostname <hostname>
git config [--global] git-town.hosting-origin-hostname <hostname>
```

`<hostname>` should match the hostname in your ssh config file. The optional
Expand Down

0 comments on commit eeea0cc

Please sign in to comment.