9 Commits

Author SHA1 Message Date
Veiko Aasa
c136f27707
gitweb: Add ability to change default branch
Now it is possible to change default branch when editing a repository.

Gitweb site shows default branch as a main branch and the 'git clone'
command checks out to default branch.

Added unit and functional tests. Splitted one large 'test_actions'
into multiple tests.

Tests performed:
- All gitweb unit and functional tests pass.
- Created a repository from a remote repository which has default
  branch other than master. Confirmed that the 'Edit repository'
  page shows correct branch and gitweb site shows this branch as
  a default branch

Closes #1925

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-09-09 14:37:17 -07:00
Veiko Aasa
d26e87661b
gitweb: Improve error handling when creating repository
If an error occurs during creation of a git repository, delete possibly
corrupted git repository directory and show more specific error message.

Closes #1829

Tests performed:
- Gitweb unit and functional tests pass
- Create a small disk for git repositories:
  > dd if=/dev/zero of=disk.img iflag=fullblock bs=128k count=100 && sync
  > mkfs.ext4 disk.img
  > mount -o loop disk.img /var/lib/git/
- Clone a large repository https://salsa.debian.org/freedombox-team/plinth
  Disk got full during cloning remote repository. Repository listing do not
  show this repository anymore. (No errors is shown to the user.)
- Fill disk space:
  > head -c 1G </dev/urandom > /var/lib/git/myfile
- Disk is full. Cloning an existing remote repository fails with an error
  message (No space left on device)
- Disk is full. Creating a new repository fails with an error message
  (No space left on device)

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-04-18 15:23:11 -04:00
Sunil Mohan Adapa
eada506b23
actions/*: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:39:36 +02:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Veiko Aasa
c99b33b40e
gitweb: Allow to import from a remote repository
- Allow to enter either name or URL when creating repository

- Validate a repository URL, allow only http and https schemes

- Set autocomplete off on the name/URL field because URL may contain
  username:password

- Check whether the repository actually exists before cloning

- Show progress info while cloning

- Actions script: new subcommand check-repo-exists and new arguments
  for the create-repo: --url, --prepare-only and --skip-prepare

- Add test for invalid URLs

Closes #1670

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Fix validating repo name in edit form]
[sunil: Don't pipe stdin of clone process, it may lead to a hang]
[sunil: Always run clone process with 'C' locale since we are parsing output]
[sunil: Cosmetic changes]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-11-04 21:16:30 -08:00
Veiko Aasa
caa336babc
gitweb: do not change working directory inside actions script
This is a good practice and maybe related to commit 83337e47

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-10-28 11:26:32 -07:00
Veiko Aasa
ba9869c030
gitweb: Validate repository name also in actions script
This prevents writing to an arbitrary directory if running actions script
as a root user.

- Included tests for invalid names

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil@medhas.org Parametrize the test case]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-10-28 11:22:20 -07:00
Veiko Aasa
c8eb5bb3ca
gitweb: Add tests for actions script
- add tests for create, edit and delete repository functions
- modify actions script to allow run actions without root privileges:
  - add argument --git-repo-root to overwrite the default root directory
    of repositories
  - add option --keep-ownership to the create-repo command to skip
    changing ownership to www-data
- actions script, repo-info command: instead of returning empty values,
  raise an error if the repository doesn't exist

Closes #1667

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil@medhas.org Remove unneeded #! directive]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-10-26 21:27:28 -07:00
Veiko Aasa
1b9dea4033
gitweb: New app for simple git hosting
Closes: #1658

Signed-off-by: Veiko Aasa veiko17@disroot.org
[sunil@medhas.org Minor styling and cosmetic changes]
[sunil@medhas.org Write comments for Apache configurations]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-10-19 19:13:54 -07:00