aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-09 13:07:45 +0200
committerMichael Muré <batolettre@gmail.com>2021-04-09 13:07:45 +0200
commit10a80f188861157b5f58bb700fe7f1c84bb4da95 (patch)
treeb6c977c4687d556b42a5b62643c6b2d113c789af /bridge
parent1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7 (diff)
downloadgit-bug-10a80f188861157b5f58bb700fe7f1c84bb4da95.tar.gz
github: minor cleanups
Diffstat (limited to 'bridge')
-rw-r--r--bridge/github/config.go2
-rw-r--r--bridge/github/export.go4
-rw-r--r--bridge/github/export_test.go2
-rw-r--r--bridge/github/import.go9
-rw-r--r--bridge/github/import_mediator.go30
5 files changed, 25 insertions, 22 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index 2b5af7fb..1e23c8ee 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -251,7 +251,7 @@ func promptUserToGoToBrowser(url, userCode string) {
fmt.Println("Please visit the following Github URL in a browser and enter your user authentication code.")
fmt.Println()
fmt.Println(" URL:", url)
- fmt.Println(" user authentiation code:", userCode)
+ fmt.Println(" user authentication code:", userCode)
fmt.Println()
}
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 1a59fbb3..264f2a23 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -504,7 +504,7 @@ func (ge *githubExporter) cacheGithubLabels(ctx context.Context, gc *githubv4.Cl
return nil
}
-func (ge *githubExporter) getLabelID(gc *githubv4.Client, label string) (string, error) {
+func (ge *githubExporter) getLabelID(label string) (string, error) {
label = strings.ToLower(label)
for cachedLabel, ID := range ge.cachedLabels {
if label == strings.ToLower(cachedLabel) {
@@ -598,7 +598,7 @@ func (ge *githubExporter) createGithubLabelV4(gc *githubv4.Client, label, labelC
func (ge *githubExporter) getOrCreateGithubLabelID(ctx context.Context, gc *githubv4.Client, repositoryID string, label bug.Label) (string, error) {
// try to get label id from cache
- labelID, err := ge.getLabelID(gc, string(label))
+ labelID, err := ge.getLabelID(string(label))
if err == nil {
return labelID, nil
}
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index b7a36bcf..78425e60 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -268,7 +268,7 @@ func TestGithubPushPull(t *testing.T) {
require.True(t, ok)
require.Equal(t, issueOrigin, target)
- //TODO: maybe more tests to ensure bug final state
+ // TODO: maybe more tests to ensure bug final state
})
}
}
diff --git a/bridge/github/import.go b/bridge/github/import.go
index 47be6374..306ef087 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -15,7 +15,7 @@ import (
"github.com/MichaelMure/git-bug/util/text"
)
-const EMPTY_TITLE_PLACEHOLDER = "<empty string>"
+const EmptyTitlePlaceholder = "<empty string>"
// githubImporter implement the Importer interface
type githubImporter struct {
@@ -196,7 +196,7 @@ func (gi *githubImporter) ensureIssue(ctx context.Context, repo *cache.RepoCache
// return an error: empty title.
title := string(issue.Title)
if title == " \u200b" { // U+200B == zero width space
- title = EMPTY_TITLE_PLACEHOLDER
+ title = EmptyTitlePlaceholder
}
var textInput string
@@ -380,7 +380,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
// function to return an error: empty title.
title := string(item.RenamedTitleEvent.CurrentTitle)
if title == " \u200b" { // U+200B == zero width space
- title = EMPTY_TITLE_PLACEHOLDER
+ title = EmptyTitlePlaceholder
}
op, err := b.SetTitleRaw(
@@ -568,6 +568,9 @@ func (gi *githubImporter) getGhost(ctx context.Context, repo *cache.RepoCache) (
return nil, err
}
user, err := gi.mediator.User(ctx, loginName)
+ if err != nil {
+ return nil, err
+ }
userName := ""
if user.Name != nil {
userName = string(*user.Name)
diff --git a/bridge/github/import_mediator.go b/bridge/github/import_mediator.go
index 825a0f98..873d5f62 100644
--- a/bridge/github/import_mediator.go
+++ b/bridge/github/import_mediator.go
@@ -11,12 +11,12 @@ import (
const (
// These values influence how fast the github graphql rate limit is exhausted.
- NUM_ISSUES = 40
- NUM_ISSUE_EDITS = 100
- NUM_TIMELINE_ITEMS = 100
- NUM_COMMENT_EDITS = 100
+ NumIssues = 40
+ NumIssueEdits = 100
+ NumTimelineItems = 100
+ NumCommentEdits = 100
- CHAN_CAPACITY = 128
+ ChanCapacity = 128
)
// importMediator provides a convenient interface to retrieve issues from the Github GraphQL API.
@@ -90,7 +90,7 @@ func NewImportMediator(ctx context.Context, client *githubv4.Client, owner, proj
owner: owner,
project: project,
since: since,
- importEvents: make(chan ImportEvent, CHAN_CAPACITY),
+ importEvents: make(chan ImportEvent, ChanCapacity),
err: nil,
}
go func() {
@@ -107,33 +107,33 @@ func newIssueVars(owner, project string, since time.Time) varmap {
"owner": githubv4.String(owner),
"name": githubv4.String(project),
"issueSince": githubv4.DateTime{Time: since},
- "issueFirst": githubv4.Int(NUM_ISSUES),
- "issueEditLast": githubv4.Int(NUM_ISSUE_EDITS),
+ "issueFirst": githubv4.Int(NumIssues),
+ "issueEditLast": githubv4.Int(NumIssueEdits),
"issueEditBefore": (*githubv4.String)(nil),
- "timelineFirst": githubv4.Int(NUM_TIMELINE_ITEMS),
+ "timelineFirst": githubv4.Int(NumTimelineItems),
"timelineAfter": (*githubv4.String)(nil),
- "commentEditLast": githubv4.Int(NUM_COMMENT_EDITS),
+ "commentEditLast": githubv4.Int(NumCommentEdits),
"commentEditBefore": (*githubv4.String)(nil),
}
}
func newIssueEditVars() varmap {
return varmap{
- "issueEditLast": githubv4.Int(NUM_ISSUE_EDITS),
+ "issueEditLast": githubv4.Int(NumIssueEdits),
}
}
func newTimelineVars() varmap {
return varmap{
- "timelineFirst": githubv4.Int(NUM_TIMELINE_ITEMS),
- "commentEditLast": githubv4.Int(NUM_COMMENT_EDITS),
+ "timelineFirst": githubv4.Int(NumTimelineItems),
+ "commentEditLast": githubv4.Int(NumCommentEdits),
"commentEditBefore": (*githubv4.String)(nil),
}
}
func newCommentEditVars() varmap {
return varmap{
- "commentEditLast": githubv4.Int(NUM_COMMENT_EDITS),
+ "commentEditLast": githubv4.Int(NumCommentEdits),
}
}
@@ -316,7 +316,7 @@ func (mm *importMediator) queryIssue(ctx context.Context, cursor githubv4.String
if cursor == "" {
vars["issueAfter"] = (*githubv4.String)(nil)
} else {
- vars["issueAfter"] = githubv4.String(cursor)
+ vars["issueAfter"] = cursor
}
query := issueQuery{}
if err := mm.mQuery(ctx, &query, vars); err != nil {