Skip to content

Commit 86e4135

Browse files
committed
Make parseAPTConfigLine public
We already have a way to go from a repository to a line, via `Repository.APTConfigLine`. There is a valid usecase to have the reverse, go from a line to a Repository: for instance some software will expect such a line as input/output (Ansible's apt_repository's repo for instance). Given that it's unlikely that the implementation of it will see breaking changes, I don't see any reason to keep it private.
1 parent 0d7233b commit 86e4135

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

repos.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (r *Repository) APTConfigLine() string {
107107

108108
var aptConfigLineRegexp = regexp.MustCompile(`^(# )?(deb|deb-src)(?: \[(.*)\])? ([^ ]+) ([^ ]+) ([^#\n]+)(?: +# *(.*))?$`)
109109

110-
func parseAPTConfigLine(line string) *Repository {
110+
func ParseAPTConfigLine(line string) *Repository {
111111
match := aptConfigLineRegexp.FindAllStringSubmatch(line, -1)
112112
if len(match) == 0 || len(match[0]) < 6 {
113113
return nil
@@ -134,7 +134,7 @@ func parseAPTConfigFile(configPath string) (RepositoryList, error) {
134134
res := RepositoryList{}
135135
for scanner.Scan() {
136136
line := scanner.Text()
137-
repo := parseAPTConfigLine(line)
137+
repo := ParseAPTConfigLine(line)
138138
if repo != nil {
139139
repo.configFile = configPath
140140
res = append(res, repo)
@@ -226,7 +226,7 @@ func RemoveRepository(repo *Repository, configFolderPath string) error {
226226
newContent := ""
227227
for scanner.Scan() {
228228
line := scanner.Text()
229-
r := parseAPTConfigLine(line)
229+
r := ParseAPTConfigLine(line)
230230
if r != nil && r.Equals(repo) {
231231
// Filter repo configs that match the repo to be removed
232232
continue
@@ -269,7 +269,7 @@ func EditRepository(old *Repository, newRepo *Repository, configFolderPath strin
269269
newContent := ""
270270
for scanner.Scan() {
271271
line := scanner.Text()
272-
r := parseAPTConfigLine(line)
272+
r := ParseAPTConfigLine(line)
273273
if r.Equals(old) {
274274
// Write the new config to replace the old one
275275
newContent += newRepo.APTConfigLine() + "\n"

0 commit comments

Comments
 (0)