From a13ba9066ea2b1b8580629e4149119fea3e2cefa Mon Sep 17 00:00:00 2001 From: Zero King Date: Tue, 8 Jan 2019 11:33:49 +0000 Subject: [PATCH] Improve code readability --- ci/portlist.go | 7 ++++--- pr/githubapi/pull_request.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ci/portlist.go b/ci/portlist.go index 47da43b..ad88269 100644 --- a/ci/portlist.go +++ b/ci/portlist.go @@ -32,9 +32,10 @@ func GetChangedPortList() ([]string, error) { } else if match = renameGrep.FindStringSubmatch(line); match == nil { continue } - if _, ok := portsFound[match[1]]; !ok { - portsFound[match[1]] = true - ports = append(ports, match[1]) + port := match[1] + if _, ok := portsFound[port]; !ok { + portsFound[port] = true + ports = append(ports, port) } } if err = gitCmd.Wait(); err != nil { diff --git a/pr/githubapi/pull_request.go b/pr/githubapi/pull_request.go index 03aad94..c95deeb 100644 --- a/pr/githubapi/pull_request.go +++ b/pr/githubapi/pull_request.go @@ -43,10 +43,11 @@ func (client *githubClient) ListChangedPortsAndFiles(owner, repo string, number } match := portGrep.FindStringSubmatch(fileName) if match != nil { - if idx, ok := portsFound[match[1]]; !ok { - ports = append(ports, match[1]) + port := match[1] + if idx, ok := portsFound[port]; !ok { + ports = append(ports, port) commitFiles = append(commitFiles, file) - portsFound[match[1]] = len(ports) - 1 + portsFound[port] = len(ports) - 1 } else { if match[2] == "Portfile" { commitFiles[idx] = file