@@ -1135,6 +1135,130 @@ def test_create_additional_settings_company_announcements_none_not_included(self
11351135
11361136 assert 'companyAnnouncements' not in settings
11371137
1138+ def test_create_additional_settings_attribution_full (self ):
1139+ """Test attribution with both commit and pr values."""
1140+ with tempfile .TemporaryDirectory () as tmpdir :
1141+ claude_dir = Path (tmpdir )
1142+ attribution = {
1143+ 'commit' : 'Custom commit attribution' ,
1144+ 'pr' : 'Custom PR attribution' ,
1145+ }
1146+
1147+ result = setup_environment .create_additional_settings (
1148+ {},
1149+ claude_dir ,
1150+ 'test-env' ,
1151+ attribution = attribution ,
1152+ )
1153+
1154+ assert result is True
1155+ settings_file = claude_dir / 'test-env-additional-settings.json'
1156+ settings = json .loads (settings_file .read_text ())
1157+
1158+ assert 'attribution' in settings
1159+ assert settings ['attribution' ]['commit' ] == 'Custom commit attribution'
1160+ assert settings ['attribution' ]['pr' ] == 'Custom PR attribution'
1161+
1162+ def test_create_additional_settings_attribution_hide_all (self ):
1163+ """Test attribution with empty strings to hide all."""
1164+ with tempfile .TemporaryDirectory () as tmpdir :
1165+ claude_dir = Path (tmpdir )
1166+ attribution = {'commit' : '' , 'pr' : '' }
1167+
1168+ result = setup_environment .create_additional_settings (
1169+ {},
1170+ claude_dir ,
1171+ 'test-env' ,
1172+ attribution = attribution ,
1173+ )
1174+
1175+ assert result is True
1176+ settings_file = claude_dir / 'test-env-additional-settings.json'
1177+ settings = json .loads (settings_file .read_text ())
1178+
1179+ assert settings ['attribution' ] == {'commit' : '' , 'pr' : '' }
1180+
1181+ def test_create_additional_settings_attribution_precedence_over_deprecated (self ):
1182+ """Test attribution takes precedence over deprecated include_co_authored_by."""
1183+ with tempfile .TemporaryDirectory () as tmpdir :
1184+ claude_dir = Path (tmpdir )
1185+ attribution = {'commit' : 'New format' , 'pr' : 'New format' }
1186+
1187+ result = setup_environment .create_additional_settings (
1188+ {},
1189+ claude_dir ,
1190+ 'test-env' ,
1191+ include_co_authored_by = False , # This should be ignored
1192+ attribution = attribution ,
1193+ )
1194+
1195+ assert result is True
1196+ settings_file = claude_dir / 'test-env-additional-settings.json'
1197+ settings = json .loads (settings_file .read_text ())
1198+
1199+ assert 'attribution' in settings
1200+ assert settings ['attribution' ] == attribution
1201+ assert 'includeCoAuthoredBy' not in settings
1202+
1203+ def test_create_additional_settings_deprecated_include_co_authored_by_false (self ):
1204+ """Test deprecated include_co_authored_by=False converts to attribution."""
1205+ with tempfile .TemporaryDirectory () as tmpdir :
1206+ claude_dir = Path (tmpdir )
1207+
1208+ result = setup_environment .create_additional_settings (
1209+ {},
1210+ claude_dir ,
1211+ 'test-env' ,
1212+ include_co_authored_by = False ,
1213+ )
1214+
1215+ assert result is True
1216+ settings_file = claude_dir / 'test-env-additional-settings.json'
1217+ settings = json .loads (settings_file .read_text ())
1218+
1219+ # Should be converted to new format
1220+ assert 'attribution' in settings
1221+ assert settings ['attribution' ] == {'commit' : '' , 'pr' : '' }
1222+ assert 'includeCoAuthoredBy' not in settings
1223+
1224+ def test_create_additional_settings_deprecated_include_co_authored_by_true (self ):
1225+ """Test deprecated include_co_authored_by=True does not override defaults."""
1226+ with tempfile .TemporaryDirectory () as tmpdir :
1227+ claude_dir = Path (tmpdir )
1228+
1229+ result = setup_environment .create_additional_settings (
1230+ {},
1231+ claude_dir ,
1232+ 'test-env' ,
1233+ include_co_authored_by = True ,
1234+ )
1235+
1236+ assert result is True
1237+ settings_file = claude_dir / 'test-env-additional-settings.json'
1238+ settings = json .loads (settings_file .read_text ())
1239+
1240+ # true -> use defaults, so neither key should be set
1241+ assert 'attribution' not in settings
1242+ assert 'includeCoAuthoredBy' not in settings
1243+
1244+ def test_create_additional_settings_attribution_none_not_included (self ):
1245+ """Test attribution not included when None."""
1246+ with tempfile .TemporaryDirectory () as tmpdir :
1247+ claude_dir = Path (tmpdir )
1248+
1249+ result = setup_environment .create_additional_settings (
1250+ {},
1251+ claude_dir ,
1252+ 'test-env' ,
1253+ attribution = None ,
1254+ )
1255+
1256+ assert result is True
1257+ settings_file = claude_dir / 'test-env-additional-settings.json'
1258+ settings = json .loads (settings_file .read_text ())
1259+
1260+ assert 'attribution' not in settings
1261+
11381262
11391263class TestCreateLauncherScript :
11401264 """Test launcher script creation."""
0 commit comments