-Hi. In this video, we are going to have a look
at how you can manage and version your code using Pharo,
and more precisely, its tool, Iceberg, coupled with GitHub, for example.
What we will do in this video is learn how to use Iceberg
which you can find under your Pharo environment in Tools, then Iceberg,
or use the shortcut Cmd+O+I.
You can see there all the different repositories, loaded or not,
that are known by the system. Here, we have got Pharo,
and we will have to add a new repository that we will define right now in GitHub.
If I switch over to GitHub... If you do not have a GitHub account,
I really encourage you to create one because it is extremely useful
to store and version your code. It will be more productive altogether.
You can go over to the Repositories tab and then click on New, the green button.
We will choose the name "MyPharoRepository",
and we will say that it is "A small Pharo repository".
Let it public. I do not need any of that so let us go over to Create repository.
We can see that we have got the MyPharoRepository.
It is completely empty. We will try to load that into Iceberg
and see what happens.
If I go back to my Pharo environment, in Iceberg,
I can click on Add.
You have different options. What we did was Clone from github.com
because we created the package there. The owner name, I will put my name.
The project name. I name it "MyPharoRepository".
And we will use HTTPS as a protocol. Basically, SSH...
You can use SSH if you create your keys
and then explain to Pharo where to find them.
But for now we will stick to HTTPS. Press Ok.
It is cloning the repository from GitHub,
and it says "No project found". But that is fine
because our project was empty to begin with.
So it is actually normal.
One thing is that you can see that you have got a small star on the left
and the name written in green.
This means that there are some changes that have not been saved or committed.
Altogether, Iceberg is quite a smart tool.
So, if you have got something written in red in the Status bar,
it can be handled pretty nicely by the tool itself.
If you double-click on that,
it will open the Working copy of MyPharoRepository.
Since the status is red, you can go over to Repair.
The changes that Iceberg wishes to make to your package
will be listed from the most likely to the least likely.
Basically, this means Create project meta-data
will be the thing we might want to do.
We will have an explanation below the different choices.
It is a good idea to read it in order to know what you are doing.
This way it will send data to the repository to add meta-data:
a .project file, meta information such as source code directory,
project name and so on. So this is what we actually need.
Let's press Ok.
This is how projects will be edited. It is good practice to add.
Click on the name of your project, go to the +. Write "src".
Ok. And click on the src.
This will make src the actual root directory for your code
and this is good practice. Leave the format to Tonel. Go to Ok.
And we can commit our first change. So, basically, "Adding meta data".
Commit.
This is our first change. The next thing we are going to do
is actually create a class and add it to our package.
Go over to our System Browser.
Create a class named "MyPharoClass" under the package "MyPharoPackage".
Let's save it.
It is extremely simple, we will not put anything inside.
You can go over to our repository, double-click on it.
This time, we would like to add a package to this repository.
Go to Add packages, select MyPharo package, click on Add.
You can see that it is still green with a small star on the left.
This means that there are some changes that we have to either save or discard.
In this case, we would like to commit them.
So, what you can do is press Commit. You go over there and press Commit.
What we will do is write a comment: "First class MyPharoClass".
We will say Commit.
Ok.
Now, what you can see, since the beginning,
we have had this small red dot on the top right corner of the Push button.
This means that, for now, our GitHub package, if I refresh the page,
is still empty because we have not pushed anything to it.
We have made all the changes in local, in our working copy.
So, what we will do is push. A window will open,
showing the different commits that you are actually going to push.
You can look inside those commits. For example,
the difference between this one and this one
is that we are adding the PharoClass within the PharoPackage.
That is great. Just press Push.
Since we are using HTTPS, we have to provide the credentials.
You have to write your GitHub username and password.
You can store them if you do not want to do this step again in the future,
and you are still using HTTPS. Press Ok.
This will push everything to origin. Origin will be on GitHub.
You can see that everything is up to date,
the small dot on the top right corner of the Push button has disappeared.
We can close that.
Close that and go over to GitHub. If I refresh the page,
you can see that we have now the .project meta-data,
the src directory. And if I go inside the src directory,
you can see that we have got the PharoPackage with the properties.
If I go inside that, we have got our PharoClass.
Everything is there.
A good thing you can do is add a README
because this will help people understand what your package is actually doing.
Within this README, as you will see in the next video,
you can put a small script to load your package
without going through GitHub and create a baseline.
Basically, I will encourage you to use Iceberg and GitHub or GitLab or anything
to version your code and store it somewhere,
because Iceberg will really help you do that and control your code,
and keep a version history. Please use it, it will really help you.