Skip to content

Commit

Permalink
Cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski committed Jul 24, 2023
1 parent f8b0aea commit f44e6ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmd/issuectl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func initListIssuesCommand(rootCmd *cobra.Command) {
}

w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)
fmt.Fprintln(w, "ID\tName\tBackend\tBranch\tRepositories\tProfile\t")
fmt.Fprintln(w, "ID\tName\tRepository Backend\tIssue Backend\tBranch\tRepositories\tProfile\t")
for issueID, issue := range issues {
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t\n", issueID, issue.Name, issue.BackendName, issue.BranchName, issue.Repositories, issue.Profile)
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t\n", issueID, issue.Name, issue.RepoBackend, issue.IssueBackend, issue.BranchName, issue.Repositories, issue.Profile)
}
w.Flush()

Expand Down
6 changes: 0 additions & 6 deletions pkg/backend_jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ func NewJiraClient(email, apiToken, baseURL string) *Jira {
}

func (j *Jira) GetIssue(owner string, repo RepoConfigName, issueID IssueID) (interface{}, error) {
issues, _, err := j.client.Issue.Search("", &jira.SearchOptions{})
if err != nil {
return nil, err
}
Log.Infof("Issues: %v", issues)

issue, _, err := j.client.Issue.Get(string(issueID), nil)
if err != nil {
return nil, err
Expand Down
2 changes: 0 additions & 2 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func LoadConfig() IssuectlConfig {
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
if err := config.Save(); err != nil {
Log.Infof("%v", err)
return config
}
return config
Expand All @@ -122,7 +121,6 @@ func LoadConfig() IssuectlConfig {
}

if err = yaml.Unmarshal(data, config); err != nil {
Log.Infof("%v", err)
return nil
}

Expand Down
27 changes: 16 additions & 11 deletions pkg/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error {
profile := config.GetProfile(config.GetCurrentProfile())
repositories := []string{}
for _, repoName := range profile.Repositories {
Log.Infof("Appending repo %v", repoName)
repositories = append(repositories, string(repoName))
}

Expand Down Expand Up @@ -57,7 +56,8 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error {
return err
}

Log.Infof("Started working on issue %v", issueID)
Log.Infof("Workspace for %v ready! 🫡", issueID)
Log.Infof("Run `issuectl workon %v` to open it in VS Code", issueID)
return nil
}

Expand Down Expand Up @@ -104,11 +104,11 @@ func getBranchName(config IssuectlConfig, issueBackend IssueBackend, profile *Pr
default:
return "", fmt.Errorf("Missing issue type")
case *github.Issue:
Log.Infof("%v", t)
Log.V(5).Infof("%v", t)
branchName := fmt.Sprintf("%v-%v", issueID, strings.ReplaceAll(*issue.(*github.Issue).Title, " ", "-"))
return branchName, nil
case *jira.Issue:
Log.Infof("%v", t)
Log.V(5).Infof("%v", t)
branchName := fmt.Sprintf("%v-%v", issueID, strings.ReplaceAll(issue.(*jira.Issue).Fields.Summary, " ", "-"))
return branchName, nil
}
Expand All @@ -118,12 +118,13 @@ func getBranchName(config IssuectlConfig, issueBackend IssueBackend, profile *Pr
func createAndAddRepositoriesToIssue(
config IssuectlConfig, profile *Profile, issueID IssueID, issueDirPath string, branchName, issueTitle string, repositories []string) (*IssueConfig, error) {
newIssue := &IssueConfig{
Name: issueTitle,
ID: issueID,
BranchName: branchName,
BackendName: "github",
Dir: issueDirPath,
Profile: profile.Name,
Name: issueTitle,
ID: issueID,
BranchName: branchName,
RepoBackend: profile.RepoBackend,
IssueBackend: profile.IssueBackend,
Dir: issueDirPath,
Profile: profile.Name,
}

for _, repoName := range repositories {
Expand All @@ -144,7 +145,7 @@ func cloneAndAddRepositoryToIssue(config IssuectlConfig, profile *Profile, issue
return fmt.Errorf("Repo %v not defined.", repoName)
}

Log.Infof("Cloning repo %v", repo.Name)
Log.V(3).Infof("Cloning repo %v", repo.Name)

repoDirPath, err := cloneRepo(repo, issueDirPath, gitUser)
if err != nil {
Expand Down Expand Up @@ -175,6 +176,8 @@ func OpenPullRequest(issueID IssueID) error {
return err
}

Log.Infof("Opening PR for issue %v in %v", issueID, profile.RepoBackend)

repo := config.GetRepository(profile.DefaultRepository)
prId, err := repoBackend.OpenPullRequest(
repo.Owner,
Expand All @@ -192,6 +195,8 @@ func OpenPullRequest(issueID IssueID) error {
if err != nil {
return err
}
Log.Infof("Linking PR %v to issue %v in %v", prId, issueID, profile.IssueBackend)

return issueBackend.LinkIssueToRepo(repo.Owner, repo.Name, issueID, strconv.Itoa(*prId))
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ type IssueID string
type IssueConfig struct {
Name string `yaml:"name"`
ID IssueID `yaml:"id"`
BackendName BackendConfigName `yaml:"backendName"`
RepoBackend BackendConfigName `yaml:"repoBackend"`
IssueBackend BackendConfigName `yaml:"issueBackend"`
BranchName string `yaml:"branchName"`
Repositories []RepoConfigName `yaml:"repositories"`
Dir string `yaml:"dir"`
Expand Down

0 comments on commit f44e6ae

Please sign in to comment.