Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439

Computer Science Courses

Related sites

Introductory Programming In Java

Lab 6

Lab 6

Code Management with GitLab

Objectives

We shall learn how to use the modern code management system (CMS) Gitto manage a software project. The base repository server is implemented usingthe GitLab API. Usage is granted by logging in with the ANU ID and the password. A project management is performed with Lightweight Directory Access Protocol(LDAP).

Logging in the GitLab

In order to manage and submit your later projects,you need to create a git repository using our GitLab server. We shall treatall remaining projects — Assignment Two, Homework 7 and Homework 8— as one project named comp6700-2016.

Creating the project

Using a standard web browser, log in to the website.Choosing LDAP tab, sign in using your normal ANU ID and password.Perform the search for project name with comp6700-20016, or simply go to

.

When the project repository page opens, locate the Fork button to create your own copy which you should name using your Uni ID, such that the resulting URL will be

	https://gitlab.cecs.anu.edu.au/u0123456/comp6700-2016.git

(where instead of u0123456 stands your own Uni ID).

Important To allow us (the lecturers and the tutor) a read access for marking, you need to add us as Reporter members of your project. Failure to do this will prevent us from cloning your repository and marking it.

Wait.

Once the project is created, a new webpage will open in which the nameof the project is displayed:

% git@gitlab.cecs.anu.edu.au:uXXXXXXX/comp6700-2016.git

with your actual ANU ID in place of uXXXXXXX. This will thethe master repository URL. You can clone it to the computer of your choice(one or several), use the cloned (aka, local) repository to work on your projects, add new items, commit the changes to the cloned repository, and push the local repository to master (the one you've just created),such that the last push before the deadline, will constitute your submission.

Assuming that you are using the Unix/Linix command line, execute the two setting commands from the topmost "black box"

% git config --global user.name "Your Actual Name"% git config --global user.email "uXXXXXXX@anu.edu.au"

(replace uXXXXXXX on your ANU ID).

But before you do all cloning etc things, two more steps need to be taken:

1. Creating and adding the public ssh-key

To facilitate the data exchange during cloning, pushing and pulling (when you update the local repository to synchronise it with changed state of the master repository — this operation is analogue of pushing, but the data flows from the master to the local), you need generate (if you have not done it before) and add your computer(on which you will be hosting the local repository) public ssh-key.Every Unis/Linux OS has this functionality by default.

Still on the new project webpage, observe the right side of the top bar, find the"Profile setting" icon , click on it.

This will lead your to the "Profile setting" page, which will already contain your nameand email. Click on the link SSH Keys at the top (right under the search box).This will open the "My SSH keys" (which should be empty). Click on the Add SSH Keybutton, it will open another page, "Add an SSH Key", with two forms:

  1. "Title" — choose the machinename to which you will be cloning the master repository and from which you copy-and-paste thessh-key, as described below; if you're using your CS account, use the name "partch"
  2. "Key" — paste there your ssh-key.

How to get the ssh-key?

  1. If you have already generated a public ssh-key:

    run the listing command on the ssh-directory (dot is important!)

    % ls -l ~/.ssh
    if the output contains a file id_rsa.pub, see its contentsby running the command cat ~/.ssh/id_rsa.pub, it shoulddisplay a long string of characters which begins with either ssh-rsaor ssh-dsa. This is your ssh-key, paste and copy it to the "Key" form (on the "Add an SSH Key" page).

  2. If the ~/.ssh/id_rsa.pub file (or,likely, the ssh directory ~/.ssh) doesn't exist, you will need to create one. Run the command on the terminal:

    % ssh-keygen -t rsa -C "$your_email"
    and it will create the ~/.ssh/id_rsa.pub file (and others too, but they are of nointerest here). Now cat ~/.ssh/id_rsa.pub will display a string like describedin the previous case. This is your ssh-key, paste and copy it to the "Key" form (on the "Add an SSH Key" page).

Adding a reporter to your project

Because the master repository will be also your submission directory, you will need to addme as a member of your project. Return back to the project webpage(https://gitlab.cecs.anu.edu.au/uXXXXXXX/comp6700-2016), and click on "Settings" Link (top right).On the "Project Settings" page, click on "Members" link (left), on the then opened page"Users with access to this project" (you should see yourself there until this moment the sole member),click on the Add users to project button, then add all three of us (remember the names?) in the form "People", and choose the access level "Reporter" — this will give us(and only me) the read access to your master repository.

Now we are all set to clone a local repository.

Cloning a local repository

On the same machine from which the ssh-key was chosen,create (somewhere convenient) a directory comp6700-2016,change into it, and run the command:

% git clone git@gitlab.cecs.anu.edu.au:uXXXXXXX/comp6700-2016.git

this will create a local repository in the directory —in which you have to changecomp6700-2016 that has the same content as the forked repository on the Gitlab server — the directoriesand the file README.md

some directories contain more files and subdirectories depending on thetask (homework 7, homework 8, assignment 2). Familiarise yourself withthe ass2 directory content, read ass2.md file,compile and run the original Assignment Two code (you are going to spendsome time by working with this program).

Modifying and adding items in a repository

The Git tool has several standard command to manage your workingrepository. By running the command git status, you can see whichitems are currently modified, added or removed from the project. If you havenot changed an existing file or added a new one, the git statuswill tell you are "up-to-date". Try to modify README.md file(for instance, that you've read it and now stared working on the assignment).Run git status again and observe the different output.

Now change into ass2 directory (where the starting code ofthe second assignment is located), compile the code and generate its documentation by running these two commands

% make compile% make doc
and observe the output of git status — it will tell you thatnow there're untracked files and suggest that you use git addto included them to the items which you can commit for the next version of theproject. But do not run git add . just yet — not every newlycreated file needs to be part of a project. Run
% make run
to observes the application execution. Study the documentation (open thefile docs/index.html in a browser), it will help you to understandthe structure of the original code. If you like, you can later remove all generated files by running the command
% make clean

Committing changes

When you've modified items which are part of the project or created new ones and added them by using git add items command,you can commit them to the new revision

git commit . -m"log message"

what goes after -m option is a log entry. It isimportant to provide a short and informative log entry with every commit you make. The dot after commit> means everything which is being tracked by git (as reported by git status); if you want tocommit only some of those tracked items, use their name explicitly, or using wild card &mash; when you are ready to commit homework 7 files but notanything else (even though those other items have changed, too), run

git commit hw7/* -m"log message for hw7"

Pushing local repository to the original ("submitting")

When in the process of your work, you have made several commits, and completed, say,the homework 7, it's time to submit it. The submission will be performed bysending the content of the local repository to the master (your forked repository on Gitlab). Git does it withthe push command:

git push

And that's it!

You will undoubtedly need additional tutorials and instructions to get familiar enough and comfortable enough with Git. Do a search for "git tutorial"and it will bring you a lot of results (too many — Git is a very populartool). Ask for advice which resource to use, check references in the (it will be uploaded on 27.04.2016), or, perhaps, check out this free onlinebook and a blog post:

Once the GitLab repository is created (and ssh-key added), you can usea GUI-client (instead of the command line). All three major OSes have a few programs likethis (some of them open source and/or free). To name the few:

Finally, you can use an IDE to open a project which is cloned from a repository. I may demonstrate how this works in lectures (time permitting),but you can discuss this possibility during this and subsequent labs.

Lab 6

Updated:  Sun 12 Jun 2016 17:27:37 AEST Responsible Officer:   JavaScript must be enabled to display this email address. Page Contact:  

+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C       ABN : 52 234 063 906