Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions models/fixtures/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@
repo_name: repo3 # TODO old or new name?
is_private: false
content: oldRepoName

-
id: 3
user_id: 11
op_type: 1 # create repo
act_user_id: 11
act_user_name: user11
repo_id: 9
repo_user_name: user11
repo_name: repo9
is_private: false
12 changes: 12 additions & 0 deletions models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false

-
id: 9
owner_id: 11
lower_name: repo9
name: repo9
is_private: false
num_issues: 0
num_closed_issues: 0
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
15 changes: 15 additions & 0 deletions models/fixtures/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,18 @@
avatar_email: user10@example.com
num_repos: 3
is_active: true

-
id: 11
lower_name: user11
name: user11
full_name: User Eleven
email: user11@example.com
passwd: password
type: 0 # individual
salt: salt
is_admin: false
avatar: avatar11
avatar_email: user11@example.com
num_repos: 1
is_active: true
10 changes: 10 additions & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,16 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
}
}

// If repo has become private, we need to set its actions to private.
if repo.IsPrivate {
_, err = e.Where("repo_id = ?", repo.ID).Cols("is_private").Update(&Action{
IsPrivate: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsPrivate: repo.IsPrivate, ? And remove the if repo.IsPrivate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already discussed this in the linked comment. As I said, "I am not sure whether having a feed that adds new events "in the past" would make much sense.".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

})
if err != nil {
return err
}
}

// Create/Remove git-daemon-export-ok for git-daemon...
daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`)
if repo.IsPrivate && com.IsExist(daemonExportFile) {
Expand Down
19 changes: 19 additions & 0 deletions models/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,22 @@ func TestGetPrivateRepositoryCount(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, int64(2), count)
}

func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

// Get sample repo and change visibility
repo, err := GetRepositoryByID(9)
repo.IsPrivate = true

// Update it
err = UpdateRepository(repo, true)
assert.NoError(t, err)

// Check visibility of action has become private
act := Action{}
_, err = x.ID(3).Get(&act)

assert.NoError(t, err)
assert.Equal(t, true, act.IsPrivate)
}