Browse Source

Windows project contents

Pierre-Yves Barriat 7 years ago
parent
commit
fb776259d2

+ 0 - 14
project/windows/README.md

@@ -3,20 +3,6 @@ We are going to do some exercises in this dummy project.
 
 It is very simple, only consists in a couple of files written in bash and you will have to write some functions there. In the end the idea is to enhance the functionality of the script with functions to say 'Hello' in different languages:
 
-| Languages                 |                                           |
-| ------------------------- | ----------------------------------------- |
-| **Dutch**: Hallo wereld! 	    | **English**: Hello world!                     |     
-| **French**: Salut monde! 	    | **German**: Hallo Welt!                       |   
-| **Italian**: Ciao mondo! 	    | **Portuguese**: Olá mundo!                    |      
-| **Spanish**: ¡Hola mundo! 	| **Catalan**: Hola món!                        |  
-| **Turkish**: Merhaba dünya!   | **Czech**: Ahoj světe!                        |  
-| **Danish**: Hej, verden! 	    | **Faroese**: Hey, heimurin!                   |       
-| **Norwegian**: Hei, verden!   | **Hawaiian**: Aroha e ao                      |    
-| **Swedish**: Hej, världen! 	| **Welsh**: Helo byd!                          |
-| **Irish**: Dia dhuit domhan! 	| **Cornish**: Dydh da bys!                     |     
-| **Afrikaans**: Hallo, wêreld! | **Latin**: Salve, munde!                      |    
-| **Lakota**: Hau oyáte 	    | **Japanese**: こんいちは世界 (konnichiwa sekai)  |
-
 In this tutorial you will learn how to make commits in the Git project, to create several branches, to push things to Gogs, and to follow a standard procedure to develop collaboratively. Afterwards, you should apply the same methods to any other collaborative development inside the ELIC department. The objectives will be achieved gradually following these topics:
 
 1.     [Set up your working environment](https://www.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/working_environment)

+ 20 - 0
project/windows/branches/README.md

@@ -0,0 +1,20 @@
+# Prepare branches
+
+Branching means you diverge from the main line of development and continue to do work without messing with that main line. Branches are instances of a repository that can be edited and version controlled in parallel. You can think of it like making an entire copy of your repository folder that you can edit, without affecting the original versions of your scripts.
+
+## Exercise 5 – Create branch in Git_Training project
+
+Go to the terminal opened in your workstation and 'cd' to the location where you cloned the project.
+
+```
+cd Git_Training
+```
+
+Create the new branch checking off from “master” branch.
+
+```
+git branch branch_name
+git checkout branch_name
+```
+
+`<branch_name>` could be the name of the language you are working on (e.g. greetings_catalan).

+ 12 - 0
project/windows/branching-website.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <link href="css/styles.css" rel="stylesheet" type="text/css">
+    <title> Branching Practice Site </title>
+  </head>
+  <body>
+    <h1> Branching </h1>
+    <h2> A website to practice branching with Git. </h2>
+    <p> This page has been created in order to practice branching with Git and GitHub. By creating branches, we can work on different versions of the same code in the same repository simultaneously!  </p>
+  </body>
+</html>

+ 60 - 0
project/windows/functions/README.md

@@ -0,0 +1,60 @@
+# Add new functions
+
+In this chapter we will create the functions to say Hello in the different languages from the table above.
+
+In the beginning you will modify the file `greetings.sh` by adding your function e.g. `say_hello_catalan()`.
+
+Then you will modify `../run.sh` to call your function.
+
+In a further chapter of this tutorial, we will merge all the calls in the same file `run.sh` and we will see how git helps on the process of resolving conflicts.
+
+#### Exercise 6 – Perform function commit
+
+Now you have time to make changes in Git_Training project, i.e. modify 'greetings.sh' file and develop your function. After that, if we check the status of our project again, Git tells us that it’s noticed a new file. We can tell Git to track a file using git add.
+
+```
+git add .
+```
+
+Git now knows that it’s supposed to keep track of 'greetings.sh', but it hasn’t recorded these changes as a commit yet. To get it to do that, we need to run one more command:
+
+```
+git commit -m "message explaining what you have done. Fixes issue #issue_number"
+```
+
+When we run `git commit`, Git takes everything we have told it to save by using `git add` and stores a copy permanently inside the special `.git` directory. This permanent copy is called a commit (or revision) and its short identifier is `f22b25e` (Your commit may have another identifier.)
+
+You can do as many commits as you wish while developing your function. If you reach a point at which any of the open issues gets solved, you can make your commit message end with `Fixes #issue_number` ([Exercise 4 – Open new issue in Git_Training project](https://www.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/gogs_issues)).
+
+If you don't specify the `-m` parameter a text editor will open automatically to allow you to write the commit message.
+
+You can now ask Git to show the project history to check that the commit was successful by using:
+
+```
+git log
+```
+
+#### Exercise 7 – Perform run script commit
+
+You can now modify `run.sh` script to add the call to your newly created function (do not forget to source the file containing the function).
+
+Test it:
+
+```
+bash run.sh
+```
+
+When you are sure it works (it greets you in english and in your choosen language), perform a separate commit by following similar steps as in previous exercise:
+
+```
+git add run.sh
+git commit
+```
+
+#### Exercise 8 – Push git_tutorial project branch
+
+```
+git push origin <branch_name>
+```
+
+where `<branch_name>` is the name used in the previous step.

+ 19 - 0
project/windows/functions/greetings.sh

@@ -0,0 +1,19 @@
+# Functions to deal with greetings
+#
+# Written by Domingo Manubens-Gil
+#
+# Barcelona Supercomputing Centre / Earth Sciences Department (BSC-ES)
+# Created: December 4, 2015
+# Adapted:
+
+#######################################
+# Say Hello in English
+# Globals:
+# Arguments: 
+# None
+# Returns:
+# None
+#######################################
+function say_hello() {
+	echo "Add same function for your language below..."
+}

+ 13 - 0
project/windows/gogs_issues/README.md

@@ -0,0 +1,13 @@
+# Prepare issues on Gogs
+
+In this chapter we will create the issues on Gogs to tell other developers in the collaborative project what are we going to develop: a bash function to say Hello in a language of your choice from the table above.
+
+Gogs is a visual layer that works on Git. It displays graphically in your web browser all the information that Git provides: the ongoing developments, the track of the modifications, browse to any point in the past, ... and on top of that, allows to discuss issues in a forum format. We will centralise all TECLIM developments in this portal. 
+
+#### Exercise 4 – Open new issue in Git_Training project
+
+*     Open the browser and go to the Gogs project Git_Training main page.
+*     Issues .. + New issue .. Submit new issue.
+*     Put the short name of your function (e.g. greetings_catalan) in the title, write a full description and put the label “enhancement”.
+*     Click on “Create issue”.
+*     You can then see a list with all the issues. Each is assigned an #issue_number.

+ 27 - 0
project/windows/pull_master/README.md

@@ -0,0 +1,27 @@
+# Pull master changes
+
+Once the project coordinator has accepted all pull requests, there is a new version of the software in the master branch. It greets you in many languages and this is preety cool, you might want to update to it.
+
+## Exercise 13 - Update master branch
+
+Following instruction from [Exercise 10 – Checkout a branch from Git_Training project](https://www.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/review), checkout the master branch.
+
+```
+git checkout master
+```
+
+To update master branch (previously checked out) you can use:
+
+#### git pull
+
+```
+git pull origin master
+```
+
+## Exercise 14 – Run final version
+
+Now you can test final `run.sh` and see the greetings in many languages !
+
+```
+bash run.sh
+```

+ 14 - 0
project/windows/pull_request/README.md

@@ -0,0 +1,14 @@
+# Create pull request
+
+Our willing at this point is that our enhancements end up in the master branch of the project and that the responsible of the project releases a new version. Before doing so we need to go through a review and testing procedure. We don't want buggy code in our release. For doing so the first step is to create a `pull request`. In that `pull request` we can kindly ask a gentle collaborator to test our function.
+
+#### Exercise 9 – Create a pull request in Git_Training project
+
+*     Open the browser and go to the Gogs project Git_Training main page.
+*     Pull requests .. New Pull Request.
+*     Choose your source branch (e.g. “greetings_catalan”) and target branch (in this case target is “master”).
+*     Click on “Compare branches”.
+*     Fill in title and description.
+*     If any comment is needed put there. You can now take advantage to ask a collaborator (the person on your right) to test your function by using this technique
+*     Assign to the project coordinator.
+*     Click on “Submit Pull Request”.

+ 84 - 0
project/windows/review/README.md

@@ -0,0 +1,84 @@
+# Review and test others' functions
+
+In this chapter we are going to go through the review and test procedure. You might have received notifications from your colleagues asking to test their branch. So the first you need to do is to checkout their branch.
+
+To know what branches are available you can use:
+
+#### git branch
+
+```
+git branch -a
+```
+
+The outputs tells what branch you are on, marked with an asterisk. By default (if you have not created any branch) you are in the master branch.
+
+```
+* master
+```
+
+## Exercise 10 – Checkout a branch from git_tutorial project
+
+Since others might have asked you to review and test new branches at this stage you would like to have a look at the code and test it. To review a code may be enough to browse it in a Gogs window.
+
+But in order to test it you have to checkout it to your `working copy` from the command line:
+
+```
+git fetch
+```
+
+(this will detect all the branches that others pushed)
+
+```
+git checkout <other_branch_name>
+```
+
+And it will update the contents of your directory giving an output similar to this:
+
+```
+Branch greetings_spanish set up to track remote branch greetings_spanish from origin.
+Switched to a new branch 'greeting_spanish'
+```
+
+**CAUTION**: If you have uncommited changes in your project and you perform a `checkout` all your changes will be dragged into the other branch. You will see a `'M'` after the checkout. To avoid that it is preferable to do always `git commit` before doing a checkout.
+
+```
+M	README.md
+Switched to branch 'master'
+Your branch is up-to-date with 'origin/master'.
+```
+
+Additionally if you have files not added happens more or less the same.
+
+**HINT**: It is very recommendable to use `git status` before a checkout. In case there is something wrong or potentially dangerous you will see a message describing the problem and suggestions to overcome it:
+
+```
+Your branch is up-to-date with 'origin/master'.
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+  greetings_catalan.sh
+
+nothing added to commit but untracked files present (use "git add" to track)
+```
+
+## Exercise 11 – Review and test
+
+Once you have checked out to the branch you have to test you can open the files in your preferred text editor and review them.
+
+To test it you only have to do:
+
+```
+bash run.sh
+```
+
+If the program does the right thing you can express your approval to the merge request:
+
+## Exercise 12 – Approve a pull request
+
+*     Open the browser and go to the Gogs project Git_Training main page.
+*     Pull requests.
+*     Choose the pull request you are willing to approve.
+*     Go to “Write” in the tab discussion, and say you are right with the pull.
+*     Click on “Add comment”.
+
+After that, the project coordinator will accept the pull requests and a new version of the software will be released.

+ 3 - 0
project/windows/styles.css

@@ -0,0 +1,3 @@
+h1 {
+  color: blue;
+}

+ 96 - 0
project/windows/working_environment/README.md

@@ -0,0 +1,96 @@
+# Set up your working environment
+## Exercise 1 – Git global configuration
+
+First of all you will have to configure git locally in your laptop:
+
+> Of course, you must have git installed. With ubuntu: **sudo apt-get install git**
+
+Open a terminal and run the following git global commands (put your name and email):
+
+```
+git config --global user.name "My name"
+git config --global user.email "my_mail@uclouvain.be"
+git config --global color.ui auto
+git config --global core.editor "vim"
+git config --global push.default simple
+```
+
+## Exercise 2 – Gogs configuration
+
+If it is the first time you try to enter in Gogs click on “Sign-in” and use your classical ELIC login.
+
+After completing this step you will need to ask access to the repositories you want. Send an email to the Gogs administrators of this (these) project(s) asking access to.
+
+## Exercise 3 – Clone into a working environment
+
+To start working you need to create a clone, called afterward “working copy” of the git_tutorial project from Gitlab in your home (or folder of your choice):
+
+```
+git clone ssh://git@www.climate.be:3022/TECLIM/Git_Training.git
+```
+
+It will ask for your username and password and you will see output like this:
+
+```
+Cloning into 'Git_Training'...
+remote: Counting objects: 3, done.
+remote: Total 3 (delta 0), reused 0 (delta 0)
+Unpacking objects: 100% (3/3), done.
+Checking connectivity... done.
+```
+
+It has created a 'Git_Training' folder and you can browse into it:
+
+```
+cd Git_Training
+```
+
+Git clone allows you to specify parameters such as the target folder. If you don't specify it the working copy will be named as the project.
+
+Hidden inside a 'working copy' resulting from a git clone there is a special '.git' directory that contains internal objects needed by git.
+
+```
+pbarriat@elixir:~/tmp/Git_Training> ls .git/
+branches  description  hooks  info  objects      refs
+config    HEAD         index  logs  packed-refs
+```
+
+It is hidden because you are not supposed to worry at all of internals of '.git'. When you type regular git commands like those in this tutorial, git, transparently writes stuff like indices, references, branch information there.
+
+When you are in a working copy you can use regular unix-like commands such as ls, touch, cp, vi, etc. Additionally you can use whatever git commands, for instance:
+
+#### git status
+
+```
+git status
+```
+
+The outputs tells you in what branch you are on. By default (if you have not specified in the clone) it clones the master branch.
+
+On branch master
+Your branch is up-to-date with 'origin/master'.
+nothing to commit, working directory clean
+
+Git status is very important. It's recommendable to use it every now and then to know the status of your branch.
+
+Moreover you can check the history of changes by using git log command:
+git log
+
+#### git log
+
+The outputs is a list of what has been changed recently, in reverse chronological order. It tells the author of the change, when it was made and the log message given.
+
+```
+commit eab1f5f77cc3c7041f6837ce15172f2be7a650b2
+Author: Pierre-Yves Barriat <pierre-yves.barriat@uclouvain.be>
+Date:   Fri Dec 4 15:19:11 2015 +0100
+
+    Initial commit for greetings functions
+
+commit 50920a3d04197bd4e52bbfdfdfefc56be23955c6
+Author: Pierre-Yves Barriat <pierre-yves.barriat@uclouvain.be>
+Date:   Thu Dec 3 19:04:16 2015 +0100
+
+    Add readme
+```
+

+ 7 - 0
project/windows/working_environment/env.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+git config --global user.name "My name"
+git config --global user.email "my_mail@uclouvain.be"
+git config --global color.ui auto
+git config --global core.editor "vim"
+git config --global push.default simple