Skip to content

Commit

Permalink
Merge pull request #148 from x-motemen/fix-fetch
Browse files Browse the repository at this point in the history
[bugfix] fix fetch subcommand
  • Loading branch information
Songmu authored Nov 12, 2023
2 parents 4c44f07 + 08a31a5 commit 8ed5fb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 6 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,24 @@ var commandFetch = &cli.Command{
return err
}
for _, path := range c.Args().Slice() {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()

e, err := entryFromReader(f)
e, err := entryFromFile(path)
if err != nil {
return err
}
blogID, err := e.blogID()
if err != nil {
return err
}

bc := conf.Get(blogID)
if bc == nil {
return fmt.Errorf("cannot find blog for %s", path)
}
b := newBroker(bc, c.App.Writer)
if _, err := b.StoreFresh(e, path); err != nil {
re, err := asEntry(b.GetEntry(e.EditURL))
if err != nil {
return err
}
if _, err := b.StoreFresh(re, path); err != nil {
return err
}
}
Expand Down
6 changes: 5 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ func TestBlogsync(t *testing.T) {
if err := appendFile(movedPath, "updated\n"); err != nil {
t.Fatal(err)
}
draftFile, err := blogsync("push", entryFile)
relPath, err := filepath.Rel(dir, entryFile)
if err != nil {
t.Fatal(err)
}
draftFile, err := blogsync("push", relPath)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 8ed5fb9

Please sign in to comment.