# إرشادات رسائل Git Commit للنماذج اللغوية ## المبادئ الأساسية 1. **اتّبع معيار Conventional Commits** (https://www.conventionalcommits.org/) 2. **اكتب باختصار ودقة** - بدون صياغة إنشائية، أو مبالغات، أو صفات غير لازمة 3. **ركّز على ما تغيّر، لا على طريقة عمله** - اشرح التغيير نفسه، وليس تفاصيل التنفيذ 4. **كل commit يغطّي تغييرًا منطقيًا واحدًا** - افصل التغييرات المرتبطة لكنها مستقلة إلى commits منفصلة 5. **اكتب بصيغة الأمر** - `add feature` وليس `added feature` أو `adds feature` 6. **أضف نص الوصف دائمًا** - لا تستخدم commits بعنوان فقط أبدًا ## هيكلة رسالة Commit ``` <type>(<scope>): <subject> <body> <footer> ``` ### Type (مطلوب) - `feat`: ميزة جديدة - `fix`: إصلاح خلل - `refactor`: تغيير في الكود لا يصلح خللًا ولا يضيف ميزة - `perf`: تحسين أداء - `style`: تغييرات أسلوب الكود مثل التنسيق أو الفواصل المنقوطة الناقصة - `test`: إضافة اختبارات أو تحديثها - `docs`: تغييرات في التوثيق - `build`: نظام البناء أو الاعتماديات الخارجية مثل npm أو gradle أو Xcode أو SPM - `ci`: تغييرات مسار CI/CD - `chore`: مهام دورية مثل gitignore أو ملفات الإعدادات أو الصيانة - `revert`: التراجع عن commit سابق ### Scope (اختياري لكن يفضّل استخدامه) يوضح منطقة التغيير: `auth`, `ui`, `api`, `db`, `i18n`, `analytics`، وغيرها. ### Subject (مطلوب) - **بحد أقصى 50 حرفًا** - **ابدأ بحرف lowercase** إلا إذا كان اسمًا خاصًا - **بدون نقطة في النهاية** - **بصيغة الأمر**: `add` وليس `added` أو `adds` - **كن محددًا**: `add email validation` وليس `add validation` ### Body (مطلوب) - **أضف نص الوصف دائمًا** - جملة واحدة على الأقل - **اشرح ما الذي تغيّر ولماذا** - قدّم سياقًا واضحًا - **اكسر السطر عند 72 حرفًا** - **افصل العنوان عن الوصف بسطر فارغ** - **استخدم نقاطًا عند وجود أكثر من تغيير** باستخدام `-` أو `*` - **اذكر أرقام issues** إذا كانت ذات علاقة - **اذكر أسماء classes أو functions أو files** عندما تساعد على فهم التغيير ### Footer (اختياري) - **التغييرات الكاسرة للتوافق**: `BREAKING CHANGE: <description>` - **مراجع issues**: `Closes #123`, `Fixes #456` - **المساهمون المشاركون**: `Co-Authored-By: Name <email>` ## كلمات وعبارات ممنوعة **لا تستخدم هذه الكلمات أبدًا** لأنها عامة، أو انطباعية، أو مبالغ فيها: ❌ Comprehensive ❌ Robust ❌ Enhanced ❌ Improved (إلا إذا حددت المقياس الذي تغيّر) ❌ Optimized (إلا إذا حددت المقياس الذي تغيّر) ❌ Better ❌ Awesome ❌ Great ❌ Amazing ❌ Powerful ❌ Seamless ❌ Elegant ❌ Clean ❌ Modern ❌ Advanced ## أمثلة جيدة وسيئة ### ❌ سيئ (بدون وصف) ``` feat(auth): add email/password login ``` **المشاكل:** - لا يوجد نص وصف - لا يوضح ما الذي تم تنفيذه فعليًا ### ❌ سيئ (وصف مبهم) ``` feat: Add awesome new login feature This commit adds a powerful new login system with robust authentication and enhanced security features. The implementation is clean and modern. ``` **المشاكل:** - صفات انطباعية مثل awesome وpowerful وrobust وenhanced وclean وmodern - لا يحدد ما الذي تمت إضافته - الوصف يتحدث عن الجودة، وليس الوظيفة الفعلية ### ✅ جيد ``` feat(auth): add email/password login with Firebase Implement login flow using Firebase Authentication. Users can now sign in with email and password. Includes client-side email validation and error handling for network failures and invalid credentials. ``` **لماذا هذا جيد:** - يذكر التقنية المستخدمة بشكل محدد (Firebase) - النطاق واضح (auth) - الوصف يوضح الوظيفة التي تمت إضافتها - يشرح حالات معالجة الأخطاء --- ### ❌ سيئ (بدون وصف) ``` fix(auth): prevent login button double-tap ``` **المشاكل:** - لا يوجد نص وصف يشرح الإصلاح ### ✅ جيد ``` fix(auth): prevent login button double-tap Disable login button after first tap to prevent duplicate authentication requests when user taps multiple times quickly. Button re-enables after authentication completes or fails. ``` **لماذا هذا جيد:** - مكتوب بصيغة الأمر - يصف المشكلة بشكل محدد - الوصف يشرح المشكلة وطريقة معالجتها --- ### ❌ سيئ ``` refactor(auth): extract helper functions Make code better and more maintainable by extracting functions. ``` **المشاكل:** - انطباعي مثل better وmaintainable - لا يوضح أي functions المقصودة ### ✅ جيد ``` refactor(auth): extract helper functions to static struct methods Convert private functions randomNonceString and sha256 into static methods of AppleSignInHelper struct to group related authentication helper logic under one namespace. ``` **لماذا هذا جيد:** - يوضح التغيير بشكل محدد - يذكر أسماء functions بدقة - الوصف يشرح السبب والهيكلة الجديدة --- ### ❌ سيئ ``` feat(i18n): add localization ``` **المشاكل:** - لا يوجد وصف - عام جدًا ### ✅ جيد ``` feat(i18n): add English and Turkish translations for login screen Create String Catalog with translations for login UI elements, alerts, and authentication errors in English and Turkish. Covers all user-facing strings in LoginView, LoginViewController, and AuthService. ``` **لماذا هذا جيد:** - يذكر اللغات بشكل محدد - النطاق واضح (i18n) - الوصف يذكر ما تمت ترجمته وأي ملفات تأثرت --- ## إرشادات Commit عند وجود عدة ملفات ### متى تفصل Commits افصل التغييرات إلى commits مستقلة عندما تكون: 1. **اهتمامات منطقية مختلفة** - ✅ Commit 1: Add function - ✅ Commit 2: Add tests for function 2. **نطاقات مختلفة** - ✅ Commit 1: `feat(ui): add button component` - ✅ Commit 2: `feat(api): add endpoint for button action` 3. **أنواع مختلفة** - ✅ Commit 1: `feat(auth): add login form` - ✅ Commit 2: `refactor(auth): extract validation logic` ### متى تجمع التغييرات في Commit واحد اجمع التغييرات في commit واحد عندما تكون: 1. **مرتبطة ببعض بشكل مباشر** - ✅ إضافة function واستخدامها داخل نفس component 2. **تغيير ذري واحد** - ✅ إعادة تسمية function عبر عدة ملفات 3. **لا تكتمل إلا معًا** - ✅ إضافة interface وتنفيذه معًا ## استراتيجية Commit على مستوى الملفات ### مثال: تغييرات LoginView إذا كان في LoginView تغييران مستقلان: **التغيير 1:** إعادة هيكلة stack view **التغيير 2:** إضافة loading indicator **افصلها إلى 2 commits:** ``` refactor(ui): extract content stack view as property in login view Change inline stack view initialization to property-based approach to centralize UI setup and reuse the stack view. Moves stack view definition from setupUI method to lazy property. ``` ``` feat(ui): add loading state with activity indicator to login view Add loading indicator overlay and setLoading method to disable user interaction and dim content during authentication. Content alpha reduces to 0.5 when loading. ``` ## إرشادات خاصة بالتوطين والترجمة ### ✅ جيد ``` feat(i18n): add English and Turkish translations Create String Catalog (Localizable.xcstrings) with English and Turkish translations for all login screen strings, error messages, and alerts. ``` ``` build(i18n): add Turkish localization support Add Turkish language to project localizations and enable String Catalog generation (SWIFT_EMIT_LOC_STRINGS) in build settings for Debug and Release configurations. ``` ``` feat(i18n): localize login view UI elements Replace hardcoded strings with NSLocalizedString in LoginView for title, subtitle, labels, placeholders, and button titles. All user-facing text now supports localization. ``` ### ❌ سيئ ``` feat: Add comprehensive multi-language support Add awesome localization system to the app. ``` ``` feat: Add translations ``` ## التغييرات الكاسرة للتوافق عند تقديم تغييرات تكسر التوافق: ``` feat(api): change authentication response structure Authentication endpoint now returns user object in 'data' field instead of root level. This allows for additional metadata in the response. BREAKING CHANGE: Update all API consumers to access response.data.user instead of response.user. Migration guide: - Before: const user = response.user - After: const user = response.data.user ``` ## ترتيب Commits عند تجهيز عدة commits، رتّبها بشكل منطقي: 1. **الاعتماديات أولًا**: أضف المكتبات أو الإعدادات قبل استخدامها 2. **الأساس قبل الميزات**: أضف models قبل views 3. **إعدادات البناء قبل الكود**: أضف build configs قبل تغييرات source 4. **الأدوات المساعدة قبل المستهلكين**: أضف helpers قبل components التي تستخدمها ### مثال على الترتيب: ``` 1. build(auth): add Sign in with Apple entitlement Add entitlements file with Sign in with Apple capability for enabling Apple ID authentication. 2. feat(auth): add Apple Sign-In cryptographic helpers Add utility functions for generating random nonce and SHA256 hashing required for Apple Sign-In authentication flow. 3. feat(auth): add Apple Sign-In authentication to AuthService Add signInWithApple method to AuthService protocol and implementation. Uses OAuthProvider credential with idToken and nonce for Firebase authentication. 4. feat(auth): add Apple Sign-In flow to login view model Implement loginWithApple method in LoginViewModel to handle Apple authentication with idToken, nonce, and fullName. 5. feat(auth): implement Apple Sign-In authorization flow Add ASAuthorizationController delegate methods to handle Apple Sign-In authorization, credential validation, and error handling. ``` ## حالات خاصة ### ملفات الإعدادات ``` chore: ignore GoogleService-Info.plist from version control Add GoogleService-Info.plist to .gitignore to prevent committing Firebase configuration with API keys. ``` ``` build: update iOS deployment target to 15.0 Change minimum iOS version from 14.0 to 15.0 to support async/await syntax in authentication flows. ``` ``` ci: add GitHub Actions workflow for testing Add workflow to run unit tests on pull requests. Runs on macOS latest with Xcode 15. ``` ### التوثيق ``` docs: add API authentication guide Document Firebase Authentication setup process, including Google Sign-In and Apple Sign-In configuration steps. ``` ``` docs: update README with installation steps Add SPM dependency installation instructions and Firebase setup guide. ``` ### إعادة الهيكلة ``` refactor(auth): convert helper functions to static struct methods Wrap Apple Sign-In helper functions in AppleSignInHelper struct with static methods to group related authentication helper logic under one namespace. Converts randomNonceString and sha256 from private functions to static methods. ``` ``` refactor(ui): extract email validation to separate method Move email validation regex logic from loginWithEmail to isValidEmail method for reuse in other authentication paths and related tests. ``` ### الأداء **حدد التحسن بالأرقام أو بالمقياس:** ❌ `perf: optimize login` ✅ ``` perf(auth): reduce login request time from 2s to 500ms Add request caching for Firebase configuration to avoid repeated network calls. Configuration is now cached after first retrieval. ``` ## متطلبات نص الوصف **الحد الأدنى لمتطلبات نص الوصف:** 1. **جملة أو جملتان كاملتان على الأقل** 2. **وصف محدد لما تغيّر** 3. **شرح سبب الحاجة للتغيير عندما لا يكون واضحًا** 4. **ذكر components أو files المتأثرة عند الحاجة** 5. **إضافة التفاصيل التقنية غير الواضحة من العنوان** ### أمثلة جيدة لنص الوصف: ``` Add loading indicator overlay and setLoading method to disable user interaction and dim content during authentication. ``` ``` Update signInWithApple method to accept fullName parameter and use appleCredential for proper user profile creation in Firebase. ``` ``` Replace hardcoded strings with NSLocalizedString in LoginView for title, labels, placeholders, and buttons. All UI text now supports English and Turkish translations. ``` ### أمثلة سيئة لنص الوصف: ❌ `Add feature.` (عام جدًا) ❌ `Updated files.` (لا يشرح ما الذي تغيّر) ❌ `Bug fix.` (لا يشرح أي خلل تم إصلاحه) ❌ `Refactoring.` (لا يشرح ما الذي أُعيدت هيكلته) ## قالب لنماذج الذكاء الاصطناعي عندما يُطلب من نموذج ذكاء اصطناعي إنشاء commits: ``` 1. Read git diff to understand ALL changes 2. Group changes by logical concern 3. Order commits by dependency 4. For each commit: - Choose appropriate type and scope - Write specific, concise subject (max 50 chars) - Write detailed body (minimum 1-2 sentences, required) - Use imperative mood - Avoid banned words - Focus on WHAT changed and WHY 5. Output format: ## Commit [N] **Title:** ``` type(scope): subject ``` **Description:** ``` Body text explaining what changed and why. Mention specific components, classes, or methods affected. Provide context. ``` **Files to add:** ```bash git add path/to/file ``` ``` ## قائمة التحقق النهائية قبل اقتراح أي commit، تأكد من التالي: - [ ] النوع صحيح (feat/fix/refactor/etc.) - [ ] النطاق محدد وله معنى - [ ] العنوان بصيغة الأمر - [ ] العنوان ≤50 حرفًا - [ ] **نص الوصف موجود (مطلوب)** - [ ] **نص الوصف يحتوي على 1-2 جمل كاملة على الأقل** - [ ] الوصف يشرح ما الذي تغيّر ولماذا - [ ] لا توجد كلمات ممنوعة - [ ] لا توجد صفات انطباعية - [ ] التغيير موصوف بشكل محدد - [ ] يذكر components أو files المتأثرة - [ ] كل commit يحتوي على تغيير منطقي واحد - [ ] الملفات مجمّعة بشكل صحيح --- ## مثال كامل لرسالة Commit ``` feat(auth): add email validation to login form Implement client-side email validation using regex pattern before sending authentication request. Validates format matches standard email pattern (user@domain.ext) and displays error message for invalid inputs. Prevents unnecessary Firebase API calls for malformed emails. ``` **ما الذي يجعله جيدًا:** - النوع والنطاق واضحان - العنوان محدد - الوصف يشرح ما تقوم به عملية التحقق - الوصف يشرح سبب الحاجة لها - يذكر الأثر العملي، وهو منع طلبات API غير الضرورية - لا يحتوي على كلمات ممنوعة - يستخدم صيغة الأمر بشكل صحيح --- **تذكّر:** رسالة commit الجيدة تجعل أي شخص يفهم التغيير بدون فتح diff. كن محددًا، مختصرًا، وموضوعيًا، وأضف دائمًا نص وصف له معنى.