Skip to content

Support pushing to an anonymous remote #1512

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
config: add function NewAnonymousRemoteConfig()
Add a new convenience function, `NewAnonymousRemoteConfig()`, that
makes an anonymous `RemoteConfig` given its URL (which is all that is
needed for an anonymous remote).

It will be used in a moment.
  • Loading branch information
mhagger committed Apr 21, 2025
commit de378fcdc2c0a4059039062f07edc0ab7b873615
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,13 @@ type RemoteConfig struct {
raw *format.Subsection
}

func NewAnonymousRemoteConfig(url string) *RemoteConfig {
return &RemoteConfig{
Name: AnonymousRemoteName,
URLs: []string{url},
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func NewAnonymousRemoteConfig(url string) *RemoteConfig {
return &RemoteConfig{
Name: AnonymousRemoteName,
URLs: []string{url},
}
}

// Validate validates the fields and sets the default values.
func (c *RemoteConfig) Validate() error {
if c.Name == "" {
Expand Down
8 changes: 8 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ func (s *ConfigSuite) TestAnonymousRemoteConfig() {
s.True(config.IsAnonymous())
}

func (s *ConfigSuite) TestNewAnonymousRemoteConfig() {
config := NewAnonymousRemoteConfig("http://foo/bar")

s.NoError(config.Validate())
s.Equal("anonymous", config.Name)
s.True(config.IsAnonymous())
}

func (s *ConfigSuite) TestRemoteConfigValidateMissingURL() {
config := &RemoteConfig{Name: "foo"}
s.ErrorIs(config.Validate(), ErrRemoteConfigEmptyURL)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy