Skip to content

Commit

Permalink
Merge pull request #704 from pachyderm/branch_in_fuse
Browse files Browse the repository at this point in the history
Branch in fuse
  • Loading branch information
jdoliner committed Aug 18, 2016
2 parents 44b78bb + e9a35fc commit fb35fa5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server/pfs/cmds/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ Files and URLs should be newline delimited.
}),
}
addShardFlags(mount)
finishCommit.Flags().BoolVarP(&debug, "debug", "d", false, "turn on debug messages")
mount.Flags().BoolVarP(&debug, "debug", "d", false, "turn on debug messages")

var result []*cobra.Command
result = append(result, repo)
Expand Down
7 changes: 7 additions & 0 deletions src/server/pfs/fuse/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,17 @@ func (d *directory) readCommits(ctx context.Context) ([]fuse.Dirent, error) {
if err != nil {
return nil, err
}
branchCommitInfos, err := d.fs.apiClient.ListBranch(d.File.Commit.Repo.Name)
if err != nil {
return nil, err
}
var result []fuse.Dirent
for _, commitInfo := range commitInfos {
result = append(result, fuse.Dirent{Name: commitInfo.Commit.ID, Type: fuse.DT_Dir})
}
for _, commitInfo := range branchCommitInfos {
result = append(result, fuse.Dirent{Name: commitInfo.Branch, Type: fuse.DT_Dir})
}
return result, nil
}

Expand Down
19 changes: 19 additions & 0 deletions src/server/pfs/fuse/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,25 @@ func TestReadCancelledCommit(t *testing.T) {
})
}

func TestListBranch(t *testing.T) {
if testing.Short() {
t.Skip("Skipped because of short mode")
}

testFuse(t, func(c client.APIClient, mountpoint string) {
repo := "TestListBranch"
require.NoError(t, c.CreateRepo(repo))
commit, err := c.StartCommit(repo, "", "master")
_, err = c.PutFile(repo, commit.ID, "file", strings.NewReader("foo\n"))
require.NoError(t, c.FinishCommit(repo, commit.ID))
dirs, err := ioutil.ReadDir(filepath.Join(mountpoint, repo))
require.NoError(t, err)
require.Equal(t, 2, len(dirs))
require.OneOfEquals(t, commit.ID, []interface{}{dirs[0].Name(), dirs[1].Name()})
require.OneOfEquals(t, "master", []interface{}{dirs[0].Name(), dirs[1].Name()})
})
}

func testFuse(
t *testing.T,
test func(client client.APIClient, mountpoint string),
Expand Down
4 changes: 3 additions & 1 deletion src/server/pfs/server/api_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ func (a *apiServer) InspectCommit(ctx context.Context, request *pfs.InspectCommi

commitInfos = pfsserver.ReduceCommitInfos(commitInfos)

if len(commitInfos) != 1 || commitInfos[0].Commit.ID != request.Commit.ID {
if len(commitInfos) != 1 ||
(commitInfos[0].Commit.ID != request.Commit.ID &&
commitInfos[0].Branch != request.Commit.ID) {
return nil, fmt.Errorf("incorrect commit returned (this is likely a bug)")
}

Expand Down

0 comments on commit fb35fa5

Please sign in to comment.