Loading branch.go 0 → 100644 +29 −0 Original line number Diff line number Diff line package juggler // Branch ... type Branch interface { Name() string SetName(string) string } // BranchData ... type BranchData struct { name string } // NewBranch ... func NewBranch() *BranchData { return &BranchData{} } // Name returns the name of the branch. func (b *BranchData) Name() string { return b.name } // SetName changes the name of the branch, and returns the old one. func (b *BranchData) SetName(name string) string { oldName := b.name b.name = name return oldName } branch_test.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package juggler remote.go 0 → 100644 +44 −0 Original line number Diff line number Diff line package juggler // Remote manages remote repository information. type Remote interface { Name() string SetName(string) string URI() string SetURI(string) string } // RemoteData contains information about remote repository connections. type RemoteData struct { name string uri string } // NewRemote initializes a new Remote structure. func NewRemote() *RemoteData { return &RemoteData{} } // Name returns the remote name. func (r *RemoteData) Name() string { return r.name } // SetName changes the name of the remote, and returns the old one. func (r *RemoteData) SetName(name string) string { oldName := r.name r.name = name return oldName } // URI returns the URI of the remote. func (r *RemoteData) URI() string { return r.uri } // SetURI changes the URI of the remote, and returns the old one. func (r *RemoteData) SetURI(uri string) string { oldURI := r.uri r.uri = uri return oldURI } remote_test.go 0 → 100644 +7 −0 Original line number Diff line number Diff line package juggler import "testing" func TestRemoteGeneral(t *testing.T) { } repository.go 0 → 100644 +70 −0 Original line number Diff line number Diff line package juggler // Repository manages repository information. type Repository interface { Name() string SetName(string) string Remotes() []*Remote AddRemote(*Remote) RemoveRemote(*Remote) Branches() []*Branch AddBranch(*Branch) RemoveBranch(*Branch) } // RepositoryData hold information about a project. type RepositoryData struct { name string remotes []*Remote branches []*Branch } const ( defaultRepositoryName = "" ) // NewRepository returns a new project structure. func NewRepository() *RepositoryData { return &RepositoryData{ name: defaultRepositoryName, remotes: []*Remote{}, } } // Name returns the name of the project. func (r *RepositoryData) Name() string { return r.name } // SetName changes the name of a project, and returns the old name. func (r *RepositoryData) SetName(name string) string { oldName := r.Name() r.name = name return oldName } // Remotes returns an array of Remote. func (r *RepositoryData) Remotes() []*Remote { return r.remotes } // AddRemote adds a new remote to the remotes. func (r *RepositoryData) AddRemote(remote *Remote) { r.remotes = append(r.remotes, remote) } // RemoveRemote removes a remote for the remotes. func (r *RepositoryData) RemoveRemote(remote *Remote) { remotes := []*Remote{} for _, current := range r.remotes { if current != remote { remotes = append(remotes, current) } } r.remotes = remotes } // Branches ... func (r *RepositoryData) Branches() []*Branch { return r.branches } Loading
branch.go 0 → 100644 +29 −0 Original line number Diff line number Diff line package juggler // Branch ... type Branch interface { Name() string SetName(string) string } // BranchData ... type BranchData struct { name string } // NewBranch ... func NewBranch() *BranchData { return &BranchData{} } // Name returns the name of the branch. func (b *BranchData) Name() string { return b.name } // SetName changes the name of the branch, and returns the old one. func (b *BranchData) SetName(name string) string { oldName := b.name b.name = name return oldName }
remote.go 0 → 100644 +44 −0 Original line number Diff line number Diff line package juggler // Remote manages remote repository information. type Remote interface { Name() string SetName(string) string URI() string SetURI(string) string } // RemoteData contains information about remote repository connections. type RemoteData struct { name string uri string } // NewRemote initializes a new Remote structure. func NewRemote() *RemoteData { return &RemoteData{} } // Name returns the remote name. func (r *RemoteData) Name() string { return r.name } // SetName changes the name of the remote, and returns the old one. func (r *RemoteData) SetName(name string) string { oldName := r.name r.name = name return oldName } // URI returns the URI of the remote. func (r *RemoteData) URI() string { return r.uri } // SetURI changes the URI of the remote, and returns the old one. func (r *RemoteData) SetURI(uri string) string { oldURI := r.uri r.uri = uri return oldURI }
remote_test.go 0 → 100644 +7 −0 Original line number Diff line number Diff line package juggler import "testing" func TestRemoteGeneral(t *testing.T) { }
repository.go 0 → 100644 +70 −0 Original line number Diff line number Diff line package juggler // Repository manages repository information. type Repository interface { Name() string SetName(string) string Remotes() []*Remote AddRemote(*Remote) RemoveRemote(*Remote) Branches() []*Branch AddBranch(*Branch) RemoveBranch(*Branch) } // RepositoryData hold information about a project. type RepositoryData struct { name string remotes []*Remote branches []*Branch } const ( defaultRepositoryName = "" ) // NewRepository returns a new project structure. func NewRepository() *RepositoryData { return &RepositoryData{ name: defaultRepositoryName, remotes: []*Remote{}, } } // Name returns the name of the project. func (r *RepositoryData) Name() string { return r.name } // SetName changes the name of a project, and returns the old name. func (r *RepositoryData) SetName(name string) string { oldName := r.Name() r.name = name return oldName } // Remotes returns an array of Remote. func (r *RepositoryData) Remotes() []*Remote { return r.remotes } // AddRemote adds a new remote to the remotes. func (r *RepositoryData) AddRemote(remote *Remote) { r.remotes = append(r.remotes, remote) } // RemoveRemote removes a remote for the remotes. func (r *RepositoryData) RemoveRemote(remote *Remote) { remotes := []*Remote{} for _, current := range r.remotes { if current != remote { remotes = append(remotes, current) } } r.remotes = remotes } // Branches ... func (r *RepositoryData) Branches() []*Branch { return r.branches }