Skip to content

Commit

Permalink
Merge pull request #4 from blacknon/develop
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
blacknon authored Feb 18, 2023
2 parents 49d8e21 + 9793fa9 commit 6fa36ba
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 40 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Blacknon. All rights reserved.
# Copyright (c) 2023 Blacknon. All rights reserved.
# Use of this source code is governed by an MIT license
# that can be found in the LICENSE file.
# reference:
Expand All @@ -13,7 +13,6 @@ on:
push:
branches:
- master
- develop

jobs:
# build rust binary
Expand Down
2 changes: 2 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func (c *Client) Get(url string) (snippet SnippetData, err error) {

snippet, err = sld.Client.Get(sld.Id)

fmt.Println("debug: snippet.Title: ", snippet.Title)

return
}

Expand Down
18 changes: 10 additions & 8 deletions client/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ func (g *GistClient) List(isFile, isSecret bool) (snippetList SnippetList, err e
}

data := SnippetListData{
Client: g,
Platform: g.PlatformName,
Id: gist.GetID(),
Description: description,
URL: gist.GetHTMLURL(),
Visibility: visibility,
Client: g,
Platform: g.PlatformName,
Id: gist.GetID(),
Title: description,
URL: gist.GetHTMLURL(),
Visibility: visibility,
}

if isFile {
Expand Down Expand Up @@ -130,6 +130,8 @@ func (g *GistClient) Get(id string) (data SnippetData, err error) {
Files: files,
}

fmt.Println("debug. gist description:", data.Title)

return
}

Expand All @@ -153,7 +155,7 @@ func (g *GistClient) Create(data SnippetData) (gist SnippetClient, err error) {
gist, _, err = g.client.Gists.Create(
g.ctx,
&github.Gist{
Description: &data.Description,
Description: &data.Title,
Files: files,
Public: &isPublic,
})
Expand All @@ -177,7 +179,7 @@ func (g *GistClient) Update(id string, data SnippetData) (gist SnippetClient, er
g.ctx,
id,
&github.Gist{
Description: &data.Description,
Description: &data.Title,
Files: files,
Public: &isPublic,
})
Expand Down
22 changes: 11 additions & 11 deletions client/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ func (g *GitlabClient) List(isFile, isSecret bool) (snippetList SnippetList, err
}

// get Description
description := replaceNewline(snippet.Title, "\\n")
title := replaceNewline(snippet.Title, "\\n")

data := SnippetListData{
Client: g,
Platform: g.PlatformName,
Id: strconv.Itoa(snippet.ID),
Description: description,
URL: snippet.WebURL,
Visibility: snippet.Visibility,
Client: g,
Platform: g.PlatformName,
Id: strconv.Itoa(snippet.ID),
Title: title,
URL: snippet.WebURL,
Visibility: snippet.Visibility,
}

// check file flag
Expand Down Expand Up @@ -370,7 +370,7 @@ func (g *GitlabClient) VisibilityList() (visibilityList []Visibility) {
}

// createGistFile
func createGitlabCreateSnippetFiles(data []SnippetFileData) (files []*gitlab.CreateSnippetFile, fileName, contents string) {
func createGitlabCreateSnippetFiles(data []SnippetFileData) (files []*gitlab.CreateSnippetFileOptions, fileName, contents string) {
// set data to files
i := 0
for _, d := range data {
Expand All @@ -379,7 +379,7 @@ func createGitlabCreateSnippetFiles(data []SnippetFileData) (files []*gitlab.Cre
filepath := d.Path

// create gitlab.SnippetFile
f := gitlab.CreateSnippetFile{
f := gitlab.CreateSnippetFileOptions{
FilePath: &filepath,
Content: &c,
}
Expand All @@ -397,15 +397,15 @@ func createGitlabCreateSnippetFiles(data []SnippetFileData) (files []*gitlab.Cre
}

// createGistFile
func createGitlabUpdateSnippetFiles(data []SnippetFileData) (files []*gitlab.UpdateSnippetFile, fileName, contents string) {
func createGitlabUpdateSnippetFiles(data []SnippetFileData) (files []*gitlab.UpdateSnippetFileOptions, fileName, contents string) {
// set data to files
i := 0
for _, d := range data {
// []byte to string
c := string(d.Contents)
filepath := d.Path

f := gitlab.UpdateSnippetFile{
f := gitlab.UpdateSnippetFileOptions{
Action: gitlab.String("update"),
FilePath: &filepath,
Content: &c,
Expand Down
15 changes: 7 additions & 8 deletions client/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ func (l SnippetList) Where(fn func(*SnippetListData) bool) (result SnippetList)

// SnippetList
type SnippetListData struct {
Client GitClient
Platform string // platform the snippet resides on. ex) Github(hogehoge)/Gitlab(fugafuga)
Id string //
Title string //
Description string //
RawURL string //
URL string //
Visibility string //
Client GitClient
Platform string // platform the snippet resides on. ex) Github(hogehoge)/Gitlab(fugafuga)
Id string //
Title string //
RawURL string //
URL string //
Visibility string //
}

type SnippetData struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func cmdActionDelete(c *cli.Context) (err error) {
// Create list
var filterText string
for _, l := range list {
t := fmt.Sprintln(l.URL, l.Platform, l.Description)
t := fmt.Sprintln(l.URL, l.Platform, l.Title)
filterText += t
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func cmdActionEdit(c *cli.Context) (err error) {
// Create list
var filterText string
for _, l := range list {
t := fmt.Sprintln(l.URL, l.Platform, l.Description)
t := fmt.Sprintln(l.URL, l.Platform, l.Title)
filterText += t
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func cmdActionGet(c *cli.Context) (err error) {
// Create list
var filterText string
for _, l := range list {
t := fmt.Sprintln(l.URL, l.Platform, l.Description)
t := fmt.Sprintln(l.URL, l.Platform, l.Title)
filterText += t
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func cmdActionList(c *cli.Context) (err error) {
u = l.RawURL
}

t := fmt.Sprintln(u, l.Visibility+": "+l.Description)
t := fmt.Sprintln(u, l.Visibility+": "+l.Title)
fmt.Print(t)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var App = &cli.App{
Name: "snipt",
Usage: "multiple remote platform snippet manager.",
Version: "0.1.1",
Version: "0.1.2",
ErrWriter: ioutil.Discard,

// Flags
Expand Down
8 changes: 7 additions & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func cmdActionUpdate(c *cli.Context) (err error) {
// Create list
var filterText string
for _, l := range list {
t := fmt.Sprintln(l.URL, l.Platform, l.Description)
t := fmt.Sprintln(l.URL, l.Platform, l.Title)
filterText += t
}

Expand All @@ -95,11 +95,15 @@ func cmdActionUpdate(c *cli.Context) (err error) {
return err
}

fmt.Println("- 1. title: ", snippetData.Title)

// Get and Set title
if title != "" {
snippetData.Title = title
}

fmt.Println("- 2. title: ", snippetData.Title)

// update visibility
if c.Bool("visibility") {
// Get platorm visibility list
Expand Down Expand Up @@ -130,6 +134,8 @@ func cmdActionUpdate(c *cli.Context) (err error) {
}
snippetData.Files = files

fmt.Println("- 3. title: ", snippetData.Title)

// update
rawURLs, err := cl.Update(url, snippetData)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/BurntSushi/toml v1.2.1
github.com/google/go-github v17.0.0+incompatible
github.com/urfave/cli/v2 v2.24.1
github.com/xanzy/go-gitlab v0.79.0
github.com/xanzy/go-gitlab v0.80.2
golang.org/x/oauth2 v0.4.0
)

Expand All @@ -31,5 +31,3 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)

replace github.com/xanzy/go-gitlab v0.79.0 => github.com/blacknon/go-gitlab v0.79.999
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/blacknon/go-gitlab v0.79.999 h1:3FPrlr8G2f/rjtBKywhQx1SL45OKFpmfMrV8c9RHWbc=
github.com/blacknon/go-gitlab v0.79.999/go.mod h1:DlByVTSXhPsJMYL6+cm8e8fTJjeBmhrXdC/yvkKKt6M=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
Expand Down Expand Up @@ -51,6 +49,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/urfave/cli/v2 v2.24.1 h1:/QYYr7g0EhwXEML8jO+8OYt5trPnLHS0p3mrgExJ5NU=
github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xanzy/go-gitlab v0.80.2 h1:CH1Q7NDklqZllox4ICVF4PwlhQGfPtE+w08Jsb74ZX0=
github.com/xanzy/go-gitlab v0.80.2/go.mod h1:DlByVTSXhPsJMYL6+cm8e8fTJjeBmhrXdC/yvkKKt6M=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down

0 comments on commit 6fa36ba

Please sign in to comment.