-2

One of my professors told me to write a shell script that checkout code.

His exact words are these :

 Write a shell script that will checkout the 'XYZ' code, compile it and run the unit tests.

This XYZ code has a git repo too.

He will be running the code in a docker container. I know that git checkout means to go to another branch but I'm not sure whether I should git clone the repo then git checkout -b new_branch or not

I have only one chance at doing this and I can't do it wrong or ask him.

What does he mean by checkout the code? I have done the other part of compiling and running the unit tests but they only work in root directory of the XYZ cloned repo.

I'm really tensed because I can't do it wrong once more. What should I add in my script file to checkout the code?

This is my script file till now.

source ./init.sh

mkdir "build"
mkdir "install"
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j 4 install
echo("Now Testing");
../install/tests/write

../install/tests/read

python ../tests/read.py

make test
Akhil
  • 41
  • 6

2 Answers2

1

Checkout is a term that essentially means "get the code from the repository and flag it as being edited" and was used at the way of handling files in SourceSafe and later Team Foundation Service. In git this is not really how it is done, but the term "checkout" is verbally used to mean "get the code from the repository". Your professor just want to se that your script fetches the (latest/current) code for the project XYZ, compile that code and runs the unit tests, if I understand you correctly.

Good luck with your assignment.

  • Thank you so much. I also felt that he wants us to get the code from the repo but want sure. I'm sure now! Ill use fetch command – Akhil Mar 22 '19 at 10:49
0

I know that git checkout means to go to another branch but I'm not sure whether I should git clone the repo then git checkout -b new_branch or not

That is why the confusing git checkout command has been replaced by:

That leaves the general version control term "checkout", which in this case means a git clone of the default branch of the repository.
That leaves you with a populated working tree you can start working with.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250