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
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
// Copyright (C) 2019-2025, Lux Partners Limited. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package workflow
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/luxfi/lpm/constant"
|
|
"github.com/luxfi/lpm/state"
|
|
)
|
|
|
|
var _ Workflow = RemoveRepository{}
|
|
|
|
func NewRemoveRepository(config RemoveRepositoryConfig) *RemoveRepository {
|
|
return &RemoveRepository{
|
|
sourcesList: config.SourcesList,
|
|
repositoriesPath: config.RepositoriesPath,
|
|
alias: config.Alias,
|
|
}
|
|
}
|
|
|
|
type RemoveRepositoryConfig struct {
|
|
SourcesList map[string]*state.SourceInfo
|
|
RepositoriesPath string
|
|
Alias string
|
|
}
|
|
|
|
type RemoveRepository struct {
|
|
sourcesList map[string]*state.SourceInfo
|
|
repositoriesPath string
|
|
alias string
|
|
}
|
|
|
|
func (r RemoveRepository) Execute() error {
|
|
if r.alias == constant.CoreAlias {
|
|
fmt.Printf("Can't remove %s (required repository).\n", constant.CoreAlias)
|
|
return nil
|
|
}
|
|
|
|
_, ok := r.sourcesList[r.alias]
|
|
|
|
repoPath := filepath.Join(r.repositoriesPath, r.alias)
|
|
if err := os.RemoveAll(repoPath); err != nil {
|
|
return err
|
|
}
|
|
|
|
if !ok {
|
|
fmt.Printf("%s is already not a tracked repository. Skipping...\n", r.alias)
|
|
return nil
|
|
}
|
|
|
|
delete(r.sourcesList, r.alias)
|
|
fmt.Printf("Successfully removed %s\n", r.alias)
|
|
return nil
|
|
}
|