Skip to content

Commit 95c7e64

Browse files
committed
start here
1 parent abf9ada commit 95c7e64

File tree

7 files changed

+70
-13
lines changed

7 files changed

+70
-13
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Students Presubmit Fork Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
Branches:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- name: test branches question
14+
run: |
15+
cd test
16+
bash branches.sh
17+
MergeConflict:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
- name: test conflict question
24+
run: |
25+
git checkout main
26+
cd test
27+
bash conflict.sh
28+
SensitiveData:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
fetch-depth: 0
34+
- name: test sensitive data question
35+
run: |
36+
git checkout main
37+
bash test/sensitive_data.sh
38+
MergeRepos:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v3
42+
with:
43+
fetch-depth: 0
44+
- name: test merge repos question
45+
run: |
46+
git checkout main
47+
cd test
48+
bash merge_repos.sh
49+
50+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- edited
88
- synchronize
99
jobs:
10-
BranchesQ:
10+
QuestionsTest:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: clone

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Git Exercise
22

3+
[![License:CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
4+
5+
36
## Guidelines
47

58
1. Fork this repo and clone your forked repo locally. **Make sure you fork ALL branches, not only `main`**
6-
2. Answer the below questions, commit your results and push them to the forked repo (make sure you push all the involved branches).
7-
3. Create a PR from branch `main` of your forked repo into `main` of the original repo.
8-
4. Make sure you pass automatic tests.
9+
2. Answer the below questions, commit your results and push them (make sure you push all the involved branches).
10+
3. Check GitHub Actions **in your forked repo** (you may need to enable it) for test results. Make sure you pass the automatic tests of the **Students Presubmit Fork Tests** workflow.
911

1012
## Branches
1113

1214
Create the following git commit tree. You can add any file you want in each commit.
1315
The message for each commit is denoted in the graph (`c1`, `c2`,..., `c12`).
14-
Note the (lightweight) tags in commit `c4` and `c8`.
16+
Note the (lightweight) tags in the merge commits and commit `c8`.
1517
Make sure to create exactly these names for branches and commit messages.
1618

1719
The parent commit of `c1` should be the last commit in branch `main` after a fresh clone of this repo (commit with message `start here`).
@@ -48,7 +50,7 @@ gitGraph
4850
**Notes**:
4951

5052
- If you've messed up the repo, you can always checkout branch main and run `git reset --hard <commit-id>` where `<commit-id>` is the commit hash from which you need to start.
51-
- By default, your tags are'nt being pushed to remote. Make sure to push your tags using the `--tags` flag in the `git push` command.
53+
- By default, your tags aren't being pushed to remote. Make sure to push your tags using the `--tags` flag in the `git push` command.
5254

5355
### Test it locally
5456

@@ -131,7 +133,7 @@ The branch content should be identical to what it was before your fix, except th
131133
There are many approaches to solve it, some are using `git reset --hard`, `git rebase` or `git cherry-pick`. Find your preferred way.
132134
You should find the branch contains the vulnerable data, learn its structure and data, and remove the vulnerable commit carefully, without loosing data committed in other commits.
133135

134-
Since you've changed the commit history, you may be needing to `--force`fully push your fixed branch to remote.
136+
The commit shouldn't be found also in remote branches. Since you've changed the commit history, you may be needing to `--force`fully push your fixed branch to remote.
135137

136138
In order to prevent this vulnerability in the future, integrate [pre commit](https://pre-commit.com/) into your repo, and add a plugin that blocks any commits that contains AWS credentials data.
137139
Verify that the tool is working - try to commit the below text and make sure pre-commit is blocking you.
@@ -185,11 +187,11 @@ You have been assigned the task of merging two different Git repositories, each
185187
The repositories were maintained by separate teams and have separate commit histories.
186188
Your goal is to **preserve the entire commit history** of both repositories while merging the code into a single Git repository, ensuring that the microservices remain functional and properly integrated with each other.
187189

188-
Merge the [GitExerciseOther](https://github.com/alonitac/GitExerciseOther.git) repo into this (GitExercise) repository.
190+
Merge the [GitExerciseOther](https://github.com/alonitac/GitExerciseOther.git) repo into this (GitProject) repository.
189191
The `main` branch of the monorepo should have the following file structure:
190192

191193
```text
192-
GitExercise
194+
GitProject
193195
└── serviceA/
194196
├── [service A files...]
195197
serviceB/

test/conflict.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ then
3939
exit 1
4040
fi
4141

42-
42+
echo -e "\n\nWell done! the conflict has been resolved correctly!"

test/sensitive_data.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ VUL_COMMIT=$(git log --all --diff-filter=A --pretty=format:"%h" -- testa)
44

55
if [ "$(echo $VUL_COMMIT | md5sum | cut -d' ' -f1)" = "$(cat test/vul_hash)" ]
66
then
7-
echo "Vulnerable commit found in your repo: $VUL_COMMIT"
7+
B=$(git branch --all --contains 5c6a2de)
8+
echo "The vulnerable commit found in your repo: $B"
89
exit 1
910
fi
1011

@@ -15,19 +16,21 @@ then
1516
exit 1
1617
fi
1718

18-
git checkout $(git branch --contains $C)
19+
git checkout feature/upgrade_angular_version
1920
files=("some_file" "some_other_file" "some_file2" "some_other_file2")
2021

2122
for file in "${files[@]}"; do
2223
if [[ ! -f "$file" ]]; then
2324
echo "File $file expected to be found in the branch"
25+
exit 1
2426
fi
2527

2628
if [[ "$(echo $file | md5sum | cut -d' ' -f1)" != "$(cat $file)" ]]; then
2729
echo "The content of $file has changed comparing to the original file"
30+
exit 1
2831
fi
2932
done
3033

3134
git checkout main
3235

33-
echo "Well done! the repo is clean from vulnerabilities"
36+
echo -e "\n\nWell done! the repo is clean from vulnerabilities"

test/vul_hash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
93621e140f2ad4522902c263af835ae3

test/vul_hash-1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
082d027

0 commit comments

Comments
 (0)