This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".
For example, if you run:
```sh
git config --global init.defaultBranch main
```
And then run these tests, you get:
```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
working_dir_test.go:71: err running "git checkout master": error:
pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
working_dir_test.go:127: err running "git checkout master":
error: pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
logger.go:130: 2022-05-17T10:05:33.665-0700 INFO creating
dir "/tmp/3762936464/repos/0/default"
working_dir_test.go:198: unexpected error: running git
clone --branch master --single-branch
file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
Cloning into '/tmp/3762936464/repos/0/default'...
warning: Could not find remote branch master to
clone.
fatal: Remote branch master not found in
upstream origin
: exit status 128
--- FAIL:
TestClone_CheckoutMergeConflict
(0.68s)
working_dir_test.go:232: err running "git checkout master": error:
pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_MasterHasDiverged (0.68s)
working_dir_test.go:344: err running "git clone --branch
master --single-branch /tmp/1931262087 .": Cloning into '.'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in
upstream origin
--- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
working_dir_test.go:415: err running "git clone --branch master
--single-branch /tmp/2356723317 .": Cloning into '.'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream
origin
FAIL
FAIL
github.com/runatlantis/atlantis/server/events
7.269s
FAIL
```
* fix: add path to WorkingDir methods
`WorkingDirLocker` and `WorkingDir` are closely related -- the former acquires a lock, which ensures that the latter can safely operate on a given file path.
In #2131 we added `path` to the `WorkingDirLocker` lock key, but neglected to add the same to `WorkingDir`.
This commit adds `path` as an argument to certain `WorkingDir` methods, and includes `path` in the directory that we use to clone the repository for a given project.
Since `path` can include certain special characters such as `/`, we encode `path` as base32 when using it as part of a file path. This should ensure no special characters are used in the filesystem, and that the value can be decoded if desired (unlike hashes such as md5).
Additional changes:
- All calls to changed methods have been updated, including unit tests
- Mocks have been regenerated for `WorkingDir` and `WorkingDirLocker`
- `working_dir_test.go`
- Commands that operate on filesystem paths have been updated to include the base32 encoded `path` value
- When running `git init`, we include `-b master` as additional arguments, to ensure that `master` is our default branch (expected by the unit tests)
* Try fixing E2E tests
* Fix DefaultPendingPlanFinder
In addition to iterating over `workspaceDirs`, also iterate over `pathDirs`, and use both `workspace` and `path` to build `repoDir`.
* Fix DefaultPendingPlanFinder unit tests
* Fix DefaultProjectCommandBuilder unit tests
Co-authored-by: Kevin Snyder <kevinsnyder@KevinSnydersMBP.lan>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-1-188.ec2.internal>
* ORCA-731 Force PR authors to rebase if master has diverged (#70)
* initial commit for undiverge apply req
* Update documentation
* Fix existing unit tests
* HasDiverged unit test
* project command runner unit test
* Global config tests cases
* update parser unit tests
* Update project_test unit tests
* Fix linting
* fix test case with logging output
* add space on readme markdown
* Remove unused variable
* remove deprecated flag option
* Use global args struct instead of passing in args
* Fix merge issue
This is two changes:
Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward
Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
- rename gh-app-key to gh-app-key-file for clarity
- change git credentials writer to append a line if there is an existing
.git-credentials file and in the case of the github app to replace the
old github app line
- removed automatically setting --write-git-creds to true when using a
github app and instead requiring this is set specifically
When using --checkout-strategy merge, we were performing the merge
without the --no-ff flag. This meant that if the branch could be merged
via a fast-forward merge (without a merge commit), then later when we
ran git rev-parse HEAD^2 to determine if the repo was at the right
commit, it would fail.
Now we merge with --no-ff which ensures the commit tree will always look
the same and git rev-parse HEAD^2 will always succeed.