diff --git a/README.md b/README.md index 3d21e0f..996773e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Overview + git_update.sh is a bash script performing a punctual synchronization of a git repository. It can either be a new clone or an update. *CAREFUL*: git_update.sh is not working-directory safe and can delete your work. ``` @@ -7,11 +8,14 @@ git_update.sh -d ~/website -r V3 $REMOTE_URL Each time this command is called, the ~/website directory is resync with corresponding git branch or tag V3. # Installation + Download the git_update.sh file. You can place it in /usr/local/bin. Dependencies: Bash and Git # Use + ## Help extract + ``` NAME git_update.sh @@ -34,24 +38,29 @@ DESCRIPTION This script will replace the destination with the wanted commit of a git repository. The history is not preserved but tags are. Untracked files remain. The git commands have been chosen so as to minimize the memory and bandwidth usages. ``` + ## Cloning + git_update.sh will only clone in an empty repository, by default the current working directory. If called in a repository with a .git directory, it will update (see below). If called in a repository with untracked files, it will fail. Only the commit and the necessary objects will be cloned. The commit can be indicated through a reference, either a tag or branch, otherwise the last commit of main is the default. *CAREFUL*: the command git branch will always show the original branch name and will not follow the eventual branch changes. git_update.sh clones using -" git clone --recurse-submodules --shallow-submodules --depth=1" +`git clone --recurse-submodules --shallow-submodules --depth=1` ## Updating + git_update.sh will update if the repository already contains a .git. Untracked files and directories will be kept. Any local modification to a tracked file or created tracked file will be deleted in favor of the new commit. The history will only contain the very last commit. git_update.sh updates using -" git fetch --tags --depth=1 --prune --prune-tags --force origin $ref - git reset --hard --recurse-submodules FETCH_HEAD - git submodule update --init --recursive --force --depth=1 --remote - git reflog expire --expire=now --all - git gc --prune=now [--aggressive]" - +``` +git fetch --tags --depth=1 --prune --prune-tags --force origin $ref +git reset --hard --recurse-submodules FETCH_HEAD +git submodule update --init --recursive --force --depth=1 --remote +git reflog expire --expire=now --all +git gc --prune=now [--aggressive]" +``` ## Examples + A) Cloning the last commit of a branch into a non-existing directory `git_update.sh -r myBranch -d myDirectory $REMOTE_URL` @@ -64,6 +73,7 @@ git gc has been called with the --aggressive option, hence the objects in the .g CAREFUL: git branch still displays the original branch name and not the one of the tag. # Development process + git_update.sh has been written by the French association Jean-Cloud (https://www.jean-cloud.net), in the process of developing Shlagernetes, an orchestration tool. Shlagernetes allows storing services on fallible second-hand servers and tries to consume the less possible resources. @@ -72,9 +82,11 @@ You can find them under /test/performance_tests. Please refer to /doc/development_explanations for more information about the tests and choices made in the elaboration of git_update.sh. # Testing + The script test_git_update.sh can be found at /test/functional_tests. It will create a repository to test on before testing. Please refer to the readme of test and the readme of test/functional_tests. # How to contribute + If you have any suggestion or question about git_update.sh, please contact us at contact@jean-cloud.org. We would be delighted to hear your feedback. Feel free to send diff files with improvement suggestions. diff --git a/test/README.md b/test/README.md index b4a4e3c..6aaee16 100644 --- a/test/README.md +++ b/test/README.md @@ -1,12 +1,16 @@ # Introduction + performance_tests contains tests who compare the memory and bandwidth usage of different Git commande in order to compare them. functional_tests contains tests who verify that git_update.sh is behaving as expected. Both rely on the same test repository that is created by test_repo_creation.sh. Both have to be run from their directory because they rely on relative paths. # Creation of the test repository + The script test_repo_creation.sh creates a remote/$REPO_NAME repository. + ## Help extract + ``` NAME test_repo_creation.sh @@ -20,34 +24,48 @@ OPTIONS -l [link] adds the linked online repository as remote and pushes changes to it. Must be en empty repository. -s creates a submodule remote/$SUB_NAME and includes it in remote/$REPO_NAME. ``` + # Description of the created repository + Here is a history of the commits: + ### branch main + commit sample0 1M created commit sample1 1M created commit sample3 5M created commit sample4 1M created commit sample3 5M deleted (tag : tagging_point) [if -s is selected] commit adding $SUB_NAME module + ### branch secondary + commit sample0 1M created commit sample1 1M created commit sample2 500K created Which gives the latest state: + ### branch main + sample0 1M sample1 1M sample4 1M + ### branch secondary + sample0 1M sample1 1M sample2 500K If the -s option is selected, the submodule is created, and integrated in the last commit of main, with this history of commits: + ### branch main + commit first 1M sample created which gives the latest state: + ### branch main + sub_sample0 \ No newline at end of file diff --git a/test/functional_tests/README.md b/test/functional_tests/README.md index 3877c47..8fab86b 100644 --- a/test/functional_tests/README.md +++ b/test/functional_tests/README.md @@ -1,13 +1,16 @@ ## Introduction + test_git_update.sh performs functional tests on git_update.sh to verify that it is behaving as planned. ## Tests + The script consists in nine tests. The three first ones test the cloning and the following test the updating of git_update.sh. Each test consists of calling git_update.sh, eventually after some modifications, and compare the result with the expected result. The comparison is done by *_check functions, which modify each a boolean *_result. If all booleans of checks conducted are true, then the boolean case* is also true and the test is a success. ## Help extract + ``` NAME test_git_update.sh @@ -30,6 +33,8 @@ DESCRIPTION TEST8: git updated, before and after changing a tag, deleting and adding files in the process TEST9: git updated fast-forward on submodule on main" ``` + ## Debugging + In case of problem, it is adviced to run test_git_update.sh -c to clean the repository. This will force test_repo_creation.sh to run again and provide a new test repository. \ No newline at end of file diff --git a/test/performance_tests/README.md b/test/performance_tests/README.md index cb4aed9..998fe14 100644 --- a/test/performance_tests/README.md +++ b/test/performance_tests/README.md @@ -1,9 +1,11 @@ ## Introduction + Our objective is to find the least-consuming method in terms of memory and bandwidth resources. We are interested in cloning one specific state of the repository. We are not interested in its history or the possibility to change it from the server where it has been cloned. The tests rely on a repository created by test_repo_creation.sh. It measures memory and bandwidth usage for different git commande. ## Tests + The script consists of twenty-nine tests (listed in the results below), based on three functions: generate_random_file, get_storage_used and get_bandwidth. generate_random_file uses the bash command dd and /dev/random. @@ -14,6 +16,8 @@ The first five tests concern cloning. The following tests involve updating the repository using different commands, with three cases for each command: after adding a file, after deleting a file, after adding then deleting a file. ## Help extract + +``` NAME performance_tests.sh SYNOPSIS @@ -63,6 +67,7 @@ DESCRIPTION TEST27: --depth=1 fetching+merging -s ours with reflog and gc after addition of a 1M file TEST28: --depth=1 fetching+merging -s ours with reflog and gc after removal of a 1M file TEST29: --depth=1 fetching+merging -s ours with reflog and gc after addition then removal of a 1M file" +``` ## To go further To learn more about the process of testing different git methods conducted, please refer to doc/developement_explanations.md. \ No newline at end of file