Граф коммитов

487 Коммитов

Автор SHA1 Сообщение Дата
Boris Mbarga b84ee4d41d
Merge pull request #117 from github/improve-repository-detection
Improve repository detection and deal with `safe.bareRepository=explicit`
2023-12-17 18:27:10 +01:00
Johannes Schindelin fb78b414e2 Be mindful of `safe.bareRepository` in the tests
As of Git v2.38.0, there is an option to prevent Git from accessing bare
repositories unless asked for explicitly (via `--git-dir` or `GIT_DIR`):
`safe.bareRepository`.

The tests of `git sizer`, however, assume that Git will access a bare
repository when the current directory points inside that repository.
This only works if `safe.bareRepository` indicates that this is safe.

If that is not the case, i.e. if `safe.bareRepository` is set to
`explicit`, Git demands that the environment variable `GIT_DIR` is set
(either explicitly, or via `--git-dir`) when accessing bare
repositories.

So let's set `GIT_DIR` for the test cases that work on bare
repositories.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-12-14 08:13:08 +01:00
Michael Haggerty a4fb754855
Merge pull request #111 from rajhawaldar/master
Update the installation steps to use 'go install'
2023-12-14 01:21:07 +01:00
Michael Haggerty d605cdb7c5 TestRepo: for bare repositories, use `NewRepositoryFromGitDir()`
There's no need to deduce the `GIT_DIR` for a bare repository.
2023-12-14 01:12:43 +01:00
Michael Haggerty f9aec5023a NewRepositoryFromPath(): function renamed from `NewRepository()` 2023-12-14 01:12:43 +01:00
Michael Haggerty 02928f10bf NewRepositoryFromGitDir(): new function
If you already have the desired `GIT_DIR`, there's no need to
determine it from the current path.
2023-12-14 01:12:43 +01:00
Michael Haggerty 51cf26bdfd smartJoin(): improve docstring 2023-12-14 01:12:43 +01:00
Michael Haggerty 39102dfaa3 findGitBin(): memoize the result 2023-12-14 01:12:33 +01:00
Michael Haggerty 1d75c744e2 Repository.IsFull(): new method
Extract a method to determine whether the repository seems to be a
full clone. Call it from `NewRepository()`.
2023-12-14 01:11:07 +01:00
Michael Haggerty 29fc88208a Repository.GitPath(): new method, extracted from `NewRepository()`
Add a method `Repository.GitPath(relPath)`, which invokes `git
rev-parse --git-path $relPath` to find the path to a file within the
Git repository.

In `NewRepository()`, instantiate the `Repository` object earlier so
that the new method can be used to find the path to `shallow`.
2023-12-14 01:10:51 +01:00
Michael Haggerty c20cbb8693 Repository.gitDir: rename member from `path`
The name `gitDir` is less ambiguous. Also rename method `Path()` to
`GitDir()`.
2023-12-13 17:58:48 +01:00
Michael Haggerty 2ed1053ff9 Stop using deprecated function `ioutil.TempDir()` 2023-12-13 17:58:40 +01:00
Boris Mbarga 8452791a05
Merge pull request #115 from github/elhmn-automate-relase-asset-upload
Generate automatic draft release
2023-11-10 12:12:34 +01:00
elhmn b1712756e4 Generate automatic draft release
We needed a way to generate draft releases for git-sizer binaries.

This commit adds a new `.github/workflows/release.yml` github action
that will generate a draft release when a new tag version is pushed.

the action will be triggered After the tag is created and pushed using:

```
git tag -as v$VERSION
git push origin v$VERSION
```
2023-11-09 17:53:13 +01:00
Boris Mbarga 9640559b0f
Merge pull request #114 from github/elhmn-upgrade-go-version
Upgrade build scripts to go1.21
2023-11-06 14:49:01 +01:00
elhmn 1b0ecde670 Upgrade build scripts to go1.21 2023-11-03 13:07:54 +01:00
rajhawaldar e8d9c2eebd
Update the installation steps to use 'go install'
Signed-off-by: rajhawaldar <rajhawaldar.in@gmail.com>
2023-09-23 10:34:59 +05:30
Boris Mbarga cc04792d0f
Merge pull request #110 from github/scan-arbitrary-roots
Scan starting at arbitrary roots
2023-08-22 14:38:52 +02:00
Michael Haggerty 5d339ec292 There's no reason to make this context cancelable 2023-08-19 15:25:51 +02:00
Michael Haggerty 9e8b14fe30 Allow arbitrary reachability roots to be fed in
Instead of only traversing objects starting at references, allow the
user to specify explicit Git objects via the command line. In that
case, the traversal includes objects reachable from those objects.
2023-08-14 21:00:19 +02:00
Michael Haggerty 897baa1a96 RefRoot: add some methods
We want to add another type of root, so start the virtualization
process.
2023-08-14 18:28:54 +02:00
Michael Haggerty 757866b5ad ScanRepositoryUsingGraph(): take a list of `RefRoot`s as argument 2023-08-14 18:16:53 +02:00
Michael Haggerty 1a2c0b5106 refSeen: make type and its members public and rename it to `RefRoot` 2023-08-14 18:16:53 +02:00
Michael Haggerty fdfa791791 ScanRepositoryUsingGraph(): take a context argument 2023-08-14 18:16:53 +02:00
Michael Haggerty 559b030c9a Collect references before starting the object traversal
This provides a better separation of concerns, which will be taken
advantage of shortly.
2023-08-14 18:16:53 +02:00
Michael Haggerty 9ed78b17d5 Graph.rg: remove member
It wasn't used.
2023-08-14 14:03:17 +02:00
Michael Haggerty 0b6d3a21c6
Merge pull request #105 from github/config-backwards-compatibility
git.Repository: invoke `git config` more backwards-compatibly
2022-12-12 17:29:26 +01:00
Michael Haggerty 6238db186d git.Repository: invoke `git config` more backwards-compatibly
Some `git-config` options that we were using (`--default`,
`--type=bool`, and `--type=int`) were only added in git 2.18, released
2018-06-21. This means that some fairly recent platforms, like Ubuntu
18.04 "bionic", don't have those features in their default `git`.

Change `git.Repository` to invoke `git config` without using those
newer options.
2022-12-03 15:20:38 +01:00
Miguel Ángel Pastor Olivar d1e15af6a7
Merge pull request #104 from github/go-pipe-dependency
Use go-pipe dependency
2022-11-30 07:20:37 +01:00
Miguel Ángel Pastor Olivar 842cb88a3e
Update go-pipe to v1.0.2.
This new versions fixes the compilation problems found in Windows
2022-11-29 13:47:25 +01:00
Miguel Ángel Pastor Olivar 35f14cc271
Use the main branch in go-pipe
If everything works as expected we will tag 1.0.2 in go-pipe
2022-11-29 13:40:06 +01:00
Miguel Ángel Pastor Olivar 36e307e503
Update the source code to use the abstraction provided by the go-pipe dependency 2022-11-29 09:53:21 +01:00
Miguel Ángel Pastor Olivar 9849429fec
Add the go-pipe dependency v1.0.1 2022-11-29 09:53:21 +01:00
Miguel Ángel Pastor Olivar 9e95b4b8a6
This code has been moved into the go-pipe library 2022-11-29 09:53:21 +01:00
Oliver Bone 6ff23aa45a
Merge pull request #103 from github/allow-file-protocol
test: fix tests use of 'file' protocol
2022-10-21 15:45:51 +01:00
Oliver Bone 2c988fab54
test: fix tests use of 'file' protocol
In response to CVE-2022-39253, Git now considers the `file://` protocol
to be unsafe by default. The default value of the  `protocol.file.allow`
config variable was changed to `user` [1], meaning that a file URL or a
local path is only trusted if it came directly from user input, and not
if it came through a command which executes a clone/fetch/push
internally.

The tests fall foul of this new requirement by attempting to run a
`git submodule add` with a local directory. Internally, this performs a
clone, which is no longer trusted because of the change described above.
This results in the command failing with a "transport 'file' not
allowed" message.

Since this is only the case for a single command, then fix the test by
setting `protocol.file.allow` to `always` when we run it.

 [1] https://github.blog/2022-10-18-git-security-vulnerabilities-announced/#cve-2022-39253
2022-10-21 14:27:59 +00:00
Michael Haggerty cc6b856f85
Merge pull request #94 from github/codeowners
Add a `CODEOWNERS` file
2021-11-16 13:02:32 +01:00
Michael Haggerty 1bd6e3ee7e
Merge pull request #92 from github/lint-action
Set up and configure actions-based linting, and clean up some more warnings
2021-11-16 12:59:58 +01:00
Michael Haggerty b43d62d6c6
Merge pull request #91 from github/use-pipe-package
Use the new `pipe` package for running external commands
2021-11-16 12:58:52 +01:00
Michael Haggerty 7dd1823523 NewObjectIter(): remove unused arg 2021-11-16 12:51:20 +01:00
Michael Haggerty 0532607b10 Add a `CODEOWNERS` file 2021-11-13 18:51:05 +01:00
Michael Haggerty 3faeb53998 .golangci.toml: add an explicit linter config
This tightens things up (including some things that have been fixed in
recent commits).
2021-11-13 18:50:35 +01:00
Michael Haggerty 15487a4f52 ObjectIter: use a pipeline 2021-11-13 18:50:35 +01:00
Michael Haggerty 9dc78e30b0 pipe.FinishEarly: suppress a different linter's warning 2021-11-13 18:50:35 +01:00
Michael Haggerty 3489e7d3ea BatchObjectIter: use a pipeline 2021-11-13 18:50:35 +01:00
Michael Haggerty 24c73607bd sizerExe(): add a `default` clause to the `switch` statement
Humor the linter.
2021-11-13 18:50:35 +01:00
Michael Haggerty 1fe34af62d ParseBatchHeader(): make function public and change its signature 2021-11-13 18:50:35 +01:00
Michael Haggerty a075a1bf15 Use `io` package in preference to `io/ioutil`
The latter is deprecated.
2021-11-13 18:50:35 +01:00
Michael Haggerty c8151f9f15 ReferenceIter: use a pipeline
Allow iteration to be canceled using a context.
2021-11-13 18:50:35 +01:00
Michael Haggerty e655a21c79 Use new-style octal constants 2021-11-13 18:50:35 +01:00