christiangalsterer / stash-filehooks-plugin Goto Github PK
View Code? Open in Web Editor NEWAn Atlassian Stash plugin to check on various file attributes, like size, name
License: Apache License 2.0
An Atlassian Stash plugin to check on various file attributes, like size, name
License: Apache License 2.0
I tried to do a git push --force after rolling back the last commit and got this error:
remote: Hook org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook failed. Error:
remote: At least one commit ID must be provided to retrieve changesets
To ssh://[email protected]:7999/test/mergetest.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:7999/test/mergetest.git'
When I worked with subversion someone checked in 200,000 files in a single commit. It would be nice if this hook could catch not only files above a certain size but also the number of files in the commit. This could be an additional configuration item when configuring the hook.
Hi, I have implemented a MergeRequestCheck - The original plugin did not allow a hook on a merge request from a repository without hook settings to one with.
I would like to create a pull request with my changes, but do not have permissions. How can I do that?
Branch name- MergeRequestCheck
For the following scenario:
The pull request is:
For the above pull request, the individual who has write access to the destination branch should be able to merge but the "Merge" button is grayed/disabled:
The file name hook is incorrectly preventing the merge from occurring. If the fork repository owner grants read access to the individual who has write access to the destination branch, the "Merge" button is no longer grayed/disabled and can proceed with the merge.
The File Name Hook is not listed in the repository's "Pre receive" hooks in the following environment:
Enhancement
We have a very large repo (over 100K changes, 10 years of history). If we enable the plugin, then pushing a new branch to the server basically causes the push to hang and eventually die, because it will check every commit since the beginning of time.
The above happens because Stash gives you a from
hash of 000000
and a to
hash of <sha>
, which will give you all changesets when you do the iteration.
There's no good fix, but a good medium term fix will be to just add a limit to how many changes are requested for a new branch push (e.g. 100).
It seems File Name Hook can only be used under Merge Checks with the last 2 releases. Is there a way to use it again under a Pre Receive hook?
We are using only file name hook where we reject commit of two files to the specific list of branches. After upgrading the plugin to the latest version a strange error occurs which suppress push to the repository (even when none of the two files were committed)
2018-03-02 19:59:24,962 WARN [threadpool:thread-4] jan.padera @1MTB2V6x1199x300436x0 ftwzfc 172.20.1.55 SSH - git-receive-pack '/<repo>' c.a.s.i.h.r.DefaultRepositoryHookService [<repo>] Error calling com.atlassian.sta sh.internal.plugin.legacy.CompositeRepositoryHook.preUpdate (org.christiangalsterer.stash-filehooks-plugin:filename-hook) java.lang.IllegalStateException: At least one commit ID must be provided to retrieve changesets at com.atlassian.bitbucket.scm.ChangesetsCommandParameters.<init>(ChangesetsCommandParameters.java:26) at com.atlassian.bitbucket.scm.ChangesetsCommandParameters.<init>(ChangesetsCommandParameters.java:10) at com.atlassian.bitbucket.scm.ChangesetsCommandParameters$Builder.build(ChangesetsCommandParameters.java:75) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.lambda$getChangesets$0(ChangesetServiceImpl.java:106) at com.atlassian.bitbucket.util.PagedIterable.iterator(PagedIterable.java:27) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.getChanges(ChangesetServiceImpl.java:49) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.getChanges(ChangesetServiceImpl.java:37) at org.christiangalsterer.stash.filehooks.plugin.hook.FileNameHook.onReceive(FileNameHook.java:76) at com.atlassian.stash.internal.plugin.legacy.PreReceiveRepositoryHookAdapter.preUpdate(PreReceiveRepositoryHookAdapter.java:29) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.lambda$preUpdate$2(CompositeRepositoryHook.java:76) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.handlingExceptions(CompositeRepositoryHook.java:92) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate(CompositeRepositoryHook.java:75) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:860) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.lambda$preUpdate$4(DefaultRepositoryHookService.java:458) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:437) at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36) at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$0(GitQuarantineHelper.java:89) at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303) at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289) at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230) at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197) at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.lang.Thread.run(Thread.java:748) ... 26 frames trimmed
It would be useful if the merge check filtered on the branch pattern like the hook does. Thanks!
If you set up a File Size Hook at the project level, and then at the repository level, change the state from 'Inherited' to 'Disabled', it doesn't generate an entry in the audit log for the repository.
I think this used to work...
Hi, I'm trying to build this plugin for bitbucket. If I run atlas-run it downloads a heap of stuff but nothing happens when I get to the local site.
I need to add it as we need the latest fix. So any instructions on building it would be great.
Thanks
From an administration point of view it would be better if the filehooks plugin was available at the project level in Bit Bucket rather than at the repository level.
When project administrators create new repositories they have to remember to enable the file hook plugin, whereas if it was enabled at project level the settings would be inherited from the project.
There are two plugins in Bit Bucket provided by Atlassian which work at the project level: Verify Committer and Reject Force Push
We have a repo containing big (>> 1MB) *.xml-files which are not detected by the setting of Max 1 MB. However *cpp-files with size >> 1 MB are detected! Is there a Limitation on what the plgin detects? Is XML treted as binary and if so why isn't it detected nevertheless? Thanks for any support! Cheers, Andreas
I would like to set up higher limit for sql files then rest.
Please help me set it up.
I have done:
Include .\.sql size: 100000
Include . size 5000 exclude .*\.sql
The version: 2.4.0 (We are still on BitBucket 4.14)
Thanks!
Let's say I'm using a check to see if a file exists in the commit list, let's say for arguments sake its.
development.env.
If we run our builder in production mode, this file will be automatically be removed and a production.env file will be created.
However if I've previously commited (but not pushed) the development.env file. The expression development.env
in the file name exclude hook even though it's technically being removed.
I know with git you can tell what status the file is (deleted or added), is it possible to add the option to exclude deleted files from the check?
Can you add support for including a textbox where we could add the company/product specific comments so that it makes easier to developers why the commit was rejected.
When you push a branch delete the plugin crashes with:
java.lang.IllegalStateException: At least one changeset ID must be provided to retrieve detailed commits
at com.atlassian.stash.content.DetailedChangesetsRequest$Builder.buildChangesetIds(DetailedChangesetsRequest.java:119) ~[stash-api-3.6.0.jar:na]
at com.atlassian.stash.content.DetailedChangesetsRequest$Builder.build(DetailedChangesetsRequest.java:83) ~[stash-api-3.6.0.jar:na]
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook$7.get(FileSizeHook.java:146) ~[na:na]
at com.atlassian.stash.util.PagedIterable.iterator(PagedIterable.java:23) ~[stash-util-3.6.0.jar:na]
at com.google.common.collect.Iterables$8.iterator(Iterables.java:709) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterables.iterators(Iterables.java:499) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterables.access$100(Iterables.java:60) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterables$2.iterator(Iterables.java:489) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterables$3.next(Iterables.java:508) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterables$3.next(Iterables.java:501) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:544) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Multimaps.index(Multimaps.java:1853) ~[guava-11.0.2-atlassian-01.jar:na]
at com.google.common.collect.Multimaps.index(Multimaps.java:1784) ~[guava-11.0.2-atlassian-01.jar:na]
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.zipWithSize(FileSizeHook.java:112) ~[na:na]
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.getChanges(FileSizeHook.java:107) ~[na:na]
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.onReceive(FileSizeHook.java:81) ~[na:na]
at com.atlassian.stash.internal.hook.repository.PreReceiveRepositoryHookAdapter$1.visit(PreReceiveRepositoryHookAdapter.java:38) [stash-service-impl-3.6.0.jar:na]
at com.atlassian.stash.internal.hook.repository.PreReceiveRepositoryHookAdapter$1.visit(PreReceiveRepositoryHookAdapter.java:33) [stash-service-impl-3.6.0.jar:na]
which I imagine is because of the 00000
that you get as a ref.
So I have a git repo where there used to be some large .bak files. No current commits should point to them, but when we do a
git tag -a tagname
git push origin tagname
the filesize hook blocks tag commit based upon size.
I could work around this if there were a way to exclude specific files from the size filter (there are only 3), but my attempts to do so have failed.
Using python and Bitbucket Server 4.2.0 (see exception log for more info)
I tried passing the following dict (gets converted to JSON) to the generic "enable" endpoint for hooks:
{u'pattern-1': u'.*',
u'size-1': 100000,
u'pattern-exclude-1': '',
u'pattern-branches-1': ''}
The problem is that "size-1" is an integer and not a string which makes the validation fail, the logs indicate that line 46 in FileSizeHookValidator.java is the problem:
try {
int size = Integer.parseInt(settings.getString(SETTINGS_SIZE_PREFIX + i, ""));
if (size < 1) {
errors.addFieldError("size-" + i, i18n.getText("filesize-hook.error.size", "Size must be an integer value larger than 0"));
}
} catch (NumberFormatException e) {
errors.addFieldError(SETTINGS_SIZE_PREFIX + i, i18n.getText("filesize-hook.error.size", "Size must be an integer value larger than 0"));
}
Attempts to enable the hook in the latest bitbucket release (6.0) results in:
"This app failed to enable. Refer to the logs for more information."
Couldn't see anything obvious in the logs though ...
For example, check that all *.sh
files have chmod +x
permission, or that all other files do not have chmod +x
permission.
If I have a branch that in the past had a commit with a large file in it, and I create a new branch where that commit is in the history, a subsequent push will fail. This is because the plugin checks all commits since the beginning of time.
Can't figure out the pattern expression as it does not appear to be standard regex.
I would expect pattern /\.(mp3|mp4)/gi
to affect the following filetypes:
The pattern only affects .mp3
and .mp4
. How would a user create a case insensitive pattern?
Hello,
The File Hooks Plugin version 3.0 is preventing new local branches to be pushed to the remote if the file name and/or file size hook are enabled:
git push -u origin feature/syee_local_branch_test
Total 0 (delta 0), reused 0 (delta 0)
remote: Communication breakdown with Bitbucket.
To ssh://dev-bitbucket/test/syee_test_repo_3.git
! [remote rejected] feature/syee_local_branch_test -> feature/syee_local_branch_test (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@dev-bitbucket/test/syee_test_repo_3.git'
If the File Name and File Size Hooks are disabled, the push succeeds:
git push -u origin feature/syee_local_branch_test
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create pull request for feature/syee_local_branch_test:
<cut>
Sylvia
Hi,
We need to reject .jar, .war, .ear, .zip and .class files.
I used the Pattern .jar|.war|.ear|.zip|.class
When we commit .js file , it also got rejected. Also some html files too.
Is there any problem in Pattern
The latest UPM update (3.0) marks this plugin is not compatible with the following text:
The currently installed app was a part of the deprecated Data Center program and the app version is now not Data Center compatible. Please update the app to a Data Center version.
According to Atlassian:
The latest UPM update (3.0.0) contains Data Center compatibility messaging, which is why you’re now seeing these messages.
You’re seeing these as Atlassian has launched a new class for marketplace data center to test if the add-ons are DC compatible. This is to ensure that those add-ons are not compromising performance of the instance. Please refer to the full announcement here A new class of Marketplace app has arrived.
As a result, you will encounter situation where the plugins are marked as incompatible. We’re still approving new apps daily as our vendors and partners update their apps to meet our new Data Center standards. Ultimately, Atlassian recommends you contact the vendor to determine compatibility at scale. For the apps released by us, we are currently working on releasing new versions but that could still take some time.
In most cases, the add-ons should still work and you won’t see any problems (as they’ve been working fine so far), but look out for any updates from vendors.
If you provide more than one file size rule that use different regexes but the same size, only the last rule is effective. The main reason is that parsed rules are kept in map by allowed size, so the newly parsed rule overwrites previous rule that used the same size.
No problem but info: File Name Hook is available elsewhere now in BB Version 5.9.1 (maybe earlier, too): See section "Pull Requests" menu item "Merge Checks".
If you have a file name pattern that is matched during a pull request, the merge button is disabled (vetoed) but the hover-over text and detailed message when merge is clicked on only lists the file names matched but not why they were vetoed. It should be a more descriptive message like "The following files in the merge matched the file name hook patterns defined: file1, file2"
I've tried committing a submodule with one small file in it with the file size hook enabled with the following configuration:
Include: .*
Size: 500000000
But I get an error like the following:
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=manager-st push -v --set-upstream origin feature/windowsUI:feature/windowsUI
POST git-receive-pack (1029 bytes)
remote: Hook org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook failed. Error:
remote: '/usr/bin/git cat-file --batch-check' exited with code 0 saying: error: unable to find df2451e48dda98c8a0fe4827ed7565ebe841643a
Pushing to http://[email protected]/git/scm/fswg/fsw.git
To http://mydomain.com/git/scm/fswg/fsw.git
! [remote rejected] feature/windowsUI -> feature/windowsUI (pre-receive hook declined)
error: failed to push some refs to 'http://[email protected]/git/scm/fswg/fsw.git'
Is this a known issue, or am I missing something?
Thanks!
One of our users has reported a NullPointerException when pushing to a repository with the FileSize Hook enabled:
$ git push origin feature/test
Enter passphrase for key '/c/Users/John.Doe/.ssh/id_rsa':
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 1.32 KiB | 450.00 KiB/s, done.
Total 17 (delta 14), reused 0 (delta 0)
remote: Repository hook org.christiangalsterer.stash-filehooks-plugin:filesize-hook failed
remote: java.lang.NullPointerException
To ssh://bitbucket.corp.com:7999/project/repo.git
! [remote rejected] feature/test -> feature/test (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:7999/project/repo.git'
From the logs, I can see the following:
2018-03-13 15:05:18,795 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git rev-list --format=%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --no-min-parents --stdin --
2018-03-13 15:05:18,800 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git diff-tree -C -r --always --format=commit %H%n%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --root --stdin --
2018-03-13 15:05:18,803 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git cat-file --batch-check
2018-03-13 15:05:18,803 WARN [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] Error calling com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate (org.christiangalsterer.stash-filehooks-plugin:filesize-hook)
java.lang.NullPointerException: null
at java.util.HashMap.merge(HashMap.java:1225)
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1553)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.christiangalsterer.stash.filehooks.plugin.hook.CachingResolver.batchResolve(CachingResolver.java:87)
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.onReceive(FileSizeHook.java:82)
at com.atlassian.stash.internal.plugin.legacy.PreReceiveRepositoryHookAdapter.preUpdate(PreReceiveRepositoryHookAdapter.java:29)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.lambda$preUpdate$2(CompositeRepositoryHook.java:76)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.handlingExceptions(CompositeRepositoryHook.java:92)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate(CompositeRepositoryHook.java:75)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:798)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:411)
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$0(GitQuarantineHelper.java:89)
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230)
at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197)
at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.lang.Thread.run(Thread.java:748)
... 26 frames trimmed
2018-03-13 15:05:18,804 INFO [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] hook 'filesize-hook' vetoed the push request
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.b.scm.ssh.SshCommandExitHandler /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600: (Exit code: 0)
We are running Bitbucket Server 5.6.2 and File Hooks plugin v3.3.1. I think this is possibly a repository-related issue as we have the File Size Hook enabled in 200+ repos and this is the only repos so far to report the problem. Have disabled the hook in this repo for now, but would be nice to understand what causes this as we appreciate the functionality the hook offers.
Any thoughts or suggestions appreciated.
Version 2.4.0 introduced file name pattern check for merge requests(pull requests), but not for the file size pattern. Request for this functionality to be added.
Hi,
Currently, this plugin is configurable at each repository level.
We want to prevent all users from uploading large files, so we will have to configure it at central level or server level.
How can we configure it at server level and not provide access to project admins to change the default values.
Please guide us if anything is already available in market.
Can we configure the values globally and make the values (text fields) not editable?
Thanks,
Rakesh
dd if=/dev/zero of=big.file bs=1024k count=1 # creating "big" file
git add big.file
git commit -m "+ big.file"
git push
# enable hook with limit 1024 bytes
git rm big.file
git commit -m "- big.file"
git push
remote: =================================
remote: File [big.file] is too large. Maximum allowed file size is 1024 bytes
remote: =================================
To ssh://[email protected]:7999/test/test.git
! [remote rejected] master -> master (pre-receive hook declined)
Reject commits with a matching file name ONLY if said file is being modified, i.e. not if the file is being created.
Hello,
I have updated Bitbucket to version 5.4.1 and updated File Hook to version 3.0.0.
I create a new repository and I activate the File Size Hook with regex
Include: .*
Size: 4096
I do a touch test for an empty file
git clone
git add --all
git commit -m "asd"
git push origin
the push fails and the bitbucket log shows:
2017-11-10 10:43:42,271 INFO [threadpool:thread-2] brian @1EE93X5x643x7473x0 1eoaj33 10.XX.XX.XX "POST /scm/test/test.git/git-receive-pack HTTP/1.1" c.a.s.i.h.r.DefaultRepositoryHookService [TEST/test[703]] hook 'filesize-hook' vetoed the push request
2017-11-10 10:43:42,273 WARN [threadpool:thread-2] c.a.s.i.hook.DefaultHookService Hook socket I/O failed before the repository/hook could be identified
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230)
at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197)
at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.lang.Thread.run(Thread.java:748)
... 11 frames trimmed
I disable the file hook, I push and it works.
I reactivate the plugin, I do a new commit and it works again.
I saw someone had the same issue:
https://community.atlassian.com/t5/Product-Apps-discussions/Unable-to-push-branch-created-locally-when-File-Hooks-plugin-is/td-p/612681
and he modified the code to:
if (refChange.getFromHash().equals("0000000000000000000000000000000000000000")) { request = new CommitsBetweenRequest.Builder(repository) .include(refChange.getToHash()) .build(); } else { request = new CommitsBetweenRequest.Builder(repositoryHookRequest.getRepository()) .exclude(refChange.getFromHash()) .include(refChange.getToHash()) .build(); }
Regards
Sometimes it is more convenient to also to specify an exclude pattern instead of a complicated exclude pattern. (See also discussion in #7)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.