From 4ea35055dadf8ff23668cadbc819081ee32caa46 Mon Sep 17 00:00:00 2001 From: Christian Agyapong Date: Sat, 4 Jan 2025 20:58:35 +0000 Subject: [PATCH] Add solution.txt with answers --- .github/workflows/auto-grading.yml | 41 ----------------------------- README.md | 31 ---------------------- solution.text | 42 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/auto-grading.yml delete mode 100644 README.md create mode 100644 solution.text diff --git a/.github/workflows/auto-grading.yml b/.github/workflows/auto-grading.yml deleted file mode 100644 index 02f6820..0000000 --- a/.github/workflows/auto-grading.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Auto Grading - -on: - pull_request: - types: [opened, synchronize] - -jobs: - grade: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Install jq - run: sudo apt-get install -y jq - - - name: Validate Solution - env: - EXPECTED_ANSWERS: ${{ secrets.EXPECTED_ANSWERS }} - run: | - if [ ! -f "solution.txt" ]; then - echo "❌ Missing solution file!" && exit 1 - fi - - # Read expected answers from secret - expected_answers=$(echo $EXPECTED_ANSWERS | jq -r '.[]') - - # Read answers from solution.txt - IFS=$'\n' read -d '' -r -a answers < solution.txt - - # Validate answers - index=0 - for expected_answer in $expected_answers; do - if [[ "${answers[$index]}" != *"$expected_answer"* ]]; then - echo "❌ Incorrect answer for question $((index+1))!" && exit 1 - fi - index=$((index+1)) - done - - echo "✅ All answers are correct!" diff --git a/README.md b/README.md deleted file mode 100644 index 90a2dff..0000000 --- a/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Git Gurus Assignment - -## Task -1. Fork this repository. -2. Clone your forked repository to your local machine. -3. Add a new file named `solution.txt`. -4. Write your answers in the file. -5. Commit your changes and push them to your forked repository. -6. Create a pull request (PR) to this repository. - -## Questions -1. What is a commit in Git? -2. What is a branch in Git? -3. What is a pull request in GitHub? -4. How do you initialize a new Git repository? -5. How do you clone a repository from GitHub? -6. How do you stage changes for a commit? -7. How do you push changes to a remote repository? - -## Submission -- Submit your pull request link before **11:59 PM today**. -- Ensure your solution meets all the requirements in the task. - -## Grading -- Grading will be automated using GitHub Actions. -- Your pull request must pass all tests to be accepted. - -## What is Forking? -Forking is when you make a copy of someone else's repository to your own GitHub account. This allows you to make changes to the project without affecting the original repository. It's like making a photocopy of a document so you can write notes on it without changing the original. - -Good luck! \ No newline at end of file diff --git a/solution.text b/solution.text new file mode 100644 index 0000000..874409e --- /dev/null +++ b/solution.text @@ -0,0 +1,42 @@ +1. What is a commit in Git? +A commit in Git represents a snapshot of your repository at a particular moment. It logs the modifications made to files and directories within the repository, enabling you to monitor the evolution of your project. + +2. What is a branch in Git? +A branch in Git is an independent development path. It allows you to work on new features or +bug fixes without affecting the main codebase. Once the work is finished, branches can be +merged back into the main branch. + +3. What is a pull request in GitHub? +A pull request in GitHub is a method of suggesting changes to a repository. +It alerts others to the updates you've made to a branch and serves as a platform +for reviewing and discussing the changes before they are integrated into the main codebase. + +4. How do you initialize a new Git repository? +To initialize a new Git repository, you can use the following command: +git init +This command sets up a new Git repository in your current directory, +allowing you to start tracking your project's files. After running this command, +you can begin adding files to the repository and making commits to track changes. + +5. How do you clone a repository from GitHub? +To clone a repository from GitHub to your local machine, follow these steps: +Go to the repository you want to clone on GitHub. +Click the "Code" button and copy the repository’s URL. +In your terminal or command line, use the following command to clone the repository: +git clone +This will create a local copy of the repository on your machine. + +6. How do you stage changes for a commit? +To stage changes in Git before committing, follow these steps: +Use the git add command to stage files you want to include in your next commit. +You can add specific files or all changed files: +git add . +This prepares the files for the next commit. After staging, you can commit the changes to your local repository. + +7. How do you push changes to a remote repository? +To push your local commits to a remote repository (e.g., GitHub), use the git push command. Here's how: +Make sure you're on the branch you want to push (e.g., main, feature-branch). +Use the following command to push your changes to the remote repository: +git push +For example, to push changes to the main branch: +git push origin main