Projects onedev server Issues #914
#914  "Checkout code" confusing when trying to execute any git on it in shell execution
wojtek opened 3 weeks ago

I was trying to perform some actions getting information from git repository only to realise that git repository during build is somewhat odd - it's in detached state (which is fine) but no branch nor tag is available. Running first git fetch resolves the issue. At first I was thinking it was caused by Shallow copy but no such option is set thus no shallow copy is performed (and git seems to think it's not shallow copied because throws an error when we include --unshallow in git fetch.

Is it by design? Could it be made that git repository during build behaves like any normal git repository after clone?

Robin Shen changed state to 'Closed' 3 weeks ago
Previous Value Current Value
Robin Shen commented 3 weeks ago

This is by design. OneDev build always runs against fixed commit. Runs "git fetch origin master" if you want to do something on branches.

wojtek commented 3 weeks ago

I'm aware it runs against fixed commit and it makes perfect sense, though even in detached HEAD state I should be able to do things with git so I'm wondering what's different in case of 1dev and errors without git fetch even though it's not a shallow clone?

Robin Shen commented 3 weeks ago

There is no branch/tag retrieved by default to save time. So if you do something against branch/tag, it will show some errors unless you fetch them first. This is normal.

wojtek commented 2 weeks ago

OK, but branch/tag is miniscule compared to history, and during build by default you clone whole repository either way so why skimp on branch/tag retrieval if it doesn't make a difference in comparison?

Robin Shen commented 2 weeks ago

I filed an improvement request to switch repository to current branch instead of detached head:
Issue #925

issue 1 of 1
Seen Builds
Issue Votes (0)
Watchers (3)
issue onedev/server#914
Please wait...
Page is in error, reload to recover