mirror of
https://github.com/luxfi/lpm.git
synced 2026-10-30 16:20:57 +00:00
- Update node v1.16.15 → v1.19.8 - Update crypto v1.17.0 → v1.17.4 - Update database v1.2.0 → v1.2.1 - Update geth v1.16.34 → v1.16.35 - Update ids v1.1.0 → v1.1.1 - Update Go 1.25 → 1.25.1 - Update copyright year to 2025
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Partners Limited. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package workflow
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-git/go-git/v5/plumbing"
|
|
|
|
"github.com/luxfi/lpm/state"
|
|
)
|
|
|
|
var _ Workflow = AddRepository{}
|
|
|
|
func NewAddRepository(config AddRepositoryConfig) *AddRepository {
|
|
return &AddRepository{
|
|
sourcesList: config.SourcesList,
|
|
alias: config.Alias,
|
|
url: config.URL,
|
|
branch: config.Branch,
|
|
}
|
|
}
|
|
|
|
type AddRepositoryConfig struct {
|
|
SourcesList map[string]*state.SourceInfo
|
|
Alias, URL string
|
|
Branch plumbing.ReferenceName
|
|
}
|
|
|
|
type AddRepository struct {
|
|
sourcesList map[string]*state.SourceInfo
|
|
alias, url string
|
|
branch plumbing.ReferenceName
|
|
}
|
|
|
|
func (a AddRepository) Execute() error {
|
|
if _, ok := a.sourcesList[a.alias]; ok {
|
|
return fmt.Errorf("%s is already registered as a repository", a.alias)
|
|
}
|
|
|
|
unsynced := &state.SourceInfo{
|
|
URL: a.url,
|
|
Branch: a.branch,
|
|
Commit: plumbing.ZeroHash.String(), // hasn't been synced yet
|
|
}
|
|
|
|
a.sourcesList[a.alias] = unsynced
|
|
return nil
|
|
}
|