This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
laboratoare:laborator00b [2014/10/10 17:47] 127.0.0.1 external edit |
laboratoare:laborator00b [2014/10/19 15:04] (current) Andrei Roșu-Cojocaru [Soluții] |
||
|---|---|---|---|
| Line 679: | Line 679: | ||
| - Să se asocieze acestei versiunii o etichetă adnotată cu numele ''v4.0.2'' și cu un mesaj care reflectă funcționalitatea sa. | - Să se asocieze acestei versiunii o etichetă adnotată cu numele ''v4.0.2'' și cu un mesaj care reflectă funcționalitatea sa. | ||
| - Să se încarce în depozitul asociat contului Github personal această ramificație. | - Să se încarce în depozitul asociat contului Github personal această ramificație. | ||
| - | - [**15 puncte**] Să se integreze funcționalitățile din ramificațiile ''pwd'' și ''cat'' în ramificația ''master'', apoi să se elimine din depozitul la distanță asociat serverului Github personal. | + | - [**15 puncte**] Să se integreze funcționalitățile din ramificațiile ''pwd'' și ''cat'' în ramificația ''master'', apoi să se elimine din depozitul la distanță asociat contului Github personal. |
| ===== Resurse ====== | ===== Resurse ====== | ||
| Line 686: | Line 686: | ||
| ===== Soluții ===== | ===== Soluții ===== | ||
| - | disponibile pe 13 octombrie 2014 | ||
| + | **3.** Specificarea variabilelor de configurare se realizează prin comenzile: | ||
| + | |||
| + | <code> | ||
| + | aipi2014@ubuntu:~$ git configure --global user.name "Some Name" | ||
| + | aipi2014@ubuntu:~$ git configure --global user.email somename@somedomain.com | ||
| + | aipi2014@ubuntu:~$ git configure --global core.editor gedit | ||
| + | aipi2014@ubuntu:~$ git configure --global merge.tool diff | ||
| + | </code> | ||
| + | |||
| + | Verificarea valorii pe care o au variabilele de configurare poate fi realizată în mai multe moduri: | ||
| + | |||
| + | <code> | ||
| + | aipi2014@ubuntu:~/GitHub$ git configure --list | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | aipi2014@ubuntu:~/GitHub$ cat .git/config | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | aipi2014@ubuntu:~/GitHub$ git config user.name | ||
| + | aipi2014@ubuntu:~/GitHub$ git config user.email | ||
| + | aipi2014@ubuntu:~/GitHub$ git config core.editor | ||
| + | aipi2014@ubuntu:~/GitHub$ git config merge.tool | ||
| + | </code> | ||
| + | |||
| + | **6.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub$ git init | ||
| + | aipi2014@ubuntu:~/GitHub$ git clone https://www.github.com/aipi2014/Laborator00.git | ||
| + | </code> | ||
| + | |||
| + | **7.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub$ cd Laborator00 | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git remote add Laborator00_somename git@github.com:somename/Laborator00.git | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename master | ||
| + | </code> | ||
| + | |||
| + | **8.** | ||
| + | **I.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout --track origin/list_directory_content | ||
| + | </code> | ||
| + | |||
| + | **II.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git merge list_directory_content | ||
| + | </code> | ||
| + | |||
| + | **III.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git branch -d list_directory_content | ||
| + | </code> | ||
| + | |||
| + | **IV.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename master | ||
| + | </code> | ||
| + | |||
| + | **9.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git log --pretty=format:"%h - %an [%ae] - %ar -> %s" --graph | ||
| + | </code> | ||
| + | |||
| + | **10.** | ||
| + | |||
| + | <file java Constants.java> | ||
| + | public interface Constants { | ||
| + | // ... | ||
| + | final public static String PRINT_WORKING_DIRECTORY_COMMAND = "pwd"; | ||
| + | // ... | ||
| + | } | ||
| + | </file> | ||
| + | |||
| + | <file java CommandParser.java> | ||
| + | // ... | ||
| + | public Path analyze(String command, Path currentDirectory, Scanner scanner) { | ||
| + | String[] parts = command.split(" "); | ||
| + | FileSystemOperations fileSystemOperations = new FileSystemOperations(); | ||
| + | switch (parts[0]) { | ||
| + | // ... | ||
| + | case Constants.PRINT_WORKING_DIRECTORY_COMMAND: | ||
| + | fileSystemOperations.printWorkingDirectory(currentDirectory); | ||
| + | break; | ||
| + | // ... | ||
| + | default: | ||
| + | System.out.println("This command is not supported"); | ||
| + | break; | ||
| + | } | ||
| + | return currentDirectory; | ||
| + | } | ||
| + | </file> | ||
| + | |||
| + | <file java FileSystemOperations.java> | ||
| + | // ... | ||
| + | public void printWorkingDirectory(Path currentDirectory) { | ||
| + | System.out.println(currentDirectory.toString()); | ||
| + | } | ||
| + | // ... | ||
| + | </file> | ||
| + | |||
| + | **I.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout -b pwd | ||
| + | // implementare functionalitate pwd | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git add . | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git tag -a v4.0.1 -m "added support for pwd command" | ||
| + | </code> | ||
| + | |||
| + | **II.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename pwd | ||
| + | </code> | ||
| + | |||
| + | **11.** | ||
| + | <file java Constants.java> | ||
| + | public interface Constants { | ||
| + | // ... | ||
| + | final public static String CATENATE = "cat"; | ||
| + | // ... | ||
| + | } | ||
| + | </file> | ||
| + | |||
| + | <file java CommandParser.java> | ||
| + | // ... | ||
| + | public Path analyze(String command, Path currentDirectory, Scanner scanner) { | ||
| + | String[] parts = command.split(" "); | ||
| + | FileSystemOperations fileSystemOperations = new FileSystemOperations(); | ||
| + | switch (parts[0]) { | ||
| + | // ... | ||
| + | case Constants.CATENATE: | ||
| + | fileSystemOperations.catenate(parts[1], currentDirectory); | ||
| + | break; | ||
| + | // ... | ||
| + | default: | ||
| + | System.out.println("This command is not supported"); | ||
| + | break; | ||
| + | } | ||
| + | return currentDirectory; | ||
| + | } | ||
| + | </file> | ||
| + | |||
| + | <file java FileSystemOperations.java> | ||
| + | // ... | ||
| + | public void catenate(String name, Path currentDirectory) { | ||
| + | Path path = checkIfExists(name, currentDirectory); | ||
| + | if (path != null && Files.isRegularFile(path) && Files.isReadable(path)) { | ||
| + | Charset charset = Charset.forName("UTF-8"); | ||
| + | try (BufferedReader bufferedReader = Files.newBufferedReader(path, charset)) { | ||
| + | String line = null; | ||
| + | while ((line = bufferedReader.readLine()) != null) | ||
| + | System.out.println(line); | ||
| + | } catch (IOException ioException) { | ||
| + | System.out.println("Operation could not be performed !"+ioException.getMessage()); | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | System.out.format("Could not display the contents of file %s!%n",name); | ||
| + | } | ||
| + | // ... | ||
| + | </file> | ||
| + | |||
| + | **I.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git branch cat | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout cat | ||
| + | // implementare functionalitate cat | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git add . | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git tag -a v4.0.2 -m "added support for cat command" | ||
| + | </code> | ||
| + | |||
| + | **II.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename cat | ||
| + | </code> | ||
| + | |||
| + | **12.** <code> | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git merge pwd | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git checkout master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git merge cat | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git mergetool | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git add . | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git commit -m "resolved conflicts between pwd and cat branches" | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename master | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename :pwd | ||
| + | aipi2014@ubuntu:~/GitHub/Laborator00$ git push Laborator00_somename :cat | ||
| + | </code> | ||