mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Add codeowners feature (#24910)
Hello. This PR adds a github like configuration for the CODEOWNERS file. Resolves: #10161
This commit is contained in:
		@@ -303,3 +303,25 @@ func TestDeleteOrphanedObjects(t *testing.T) {
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
	assert.EqualValues(t, countBefore, countAfter)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestParseCodeOwnersLine(t *testing.T) {
 | 
			
		||||
	type CodeOwnerTest struct {
 | 
			
		||||
		Line   string
 | 
			
		||||
		Tokens []string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	given := []CodeOwnerTest{
 | 
			
		||||
		{Line: "", Tokens: nil},
 | 
			
		||||
		{Line: "# comment", Tokens: []string{}},
 | 
			
		||||
		{Line: "!.* @user1 @org1/team1", Tokens: []string{"!.*", "@user1", "@org1/team1"}},
 | 
			
		||||
		{Line: `.*\\.js @user2 #comment`, Tokens: []string{`.*\.js`, "@user2"}},
 | 
			
		||||
		{Line: `docs/(aws|google|azure)/[^/]*\\.(md|txt) @user3 @org2/team2`, Tokens: []string{`docs/(aws|google|azure)/[^/]*\.(md|txt)`, "@user3", "@org2/team2"}},
 | 
			
		||||
		{Line: `\#path @user3`, Tokens: []string{`#path`, "@user3"}},
 | 
			
		||||
		{Line: `path\ with\ spaces/ @user3`, Tokens: []string{`path with spaces/`, "@user3"}},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, g := range given {
 | 
			
		||||
		tokens := issues_model.TokenizeCodeOwnersLine(g.Line)
 | 
			
		||||
		assert.Equal(t, g.Tokens, tokens, "Codeowners tokenizer failed")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user