Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

May be bug in BranchSelector?

Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2013

I am trying to investigate the way _the one_ tutorial for BranchSelector works:

https://developer.atlassian.com/stash/docs/latest/how-tos/repo-hook-examples/pre-receive-branch-config.html

https://bitbucket.org/atlassian/stash-example-hook-protect-ref

with one detail : It doesnt work! It fails with error.

The error is:

Uncaught TypeError: Cannot call method 'getProject' of undefined (revision-reference-selector.js:181)
Lets go to bug-lines:

RevisionReferenceSelector.prototype.getBranchesUrl = function(){
	return nav.rest().project(this.repository.getProject()).repo(this.repository).branches().build();
			-- Uncaught TypeError: Cannot call method 'getProject' of undefined
};

I made very interesting conclude after reading relates src.
1.(this.repository) returns (pageState.getRepository)
2.If I clear about stash-parent/webapp/default/src/main/webapp/static/model/page-state.js
then getRepository() is formed dynamicaly by method function addCustomProperty(key, getterFn, setterFn) {}.
Apparently, this step is succesful.
3.getProject() is formed dynamicaly too. But there is no such method on the moment js calls it.
So it seems to be 2 reason of mistake:
1)There is no adding of property Project in function addCustomProperty(). And function getProject()
will never be added in pageState context.
If so, I'll make bug report with hope atlassian.devs fix it on demand.
2)Or, property Project is added in function addCustomProperty() but after BranchSelector functionality
have finished its deal.
If so, my question is - how do I can configure the order js formed from simple.soy is executed?
PS Sorry for my eng.
PSS May be my investigation is wrong, so It will be nice to point the way treat this error.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

It fixed in 2.6.0 due to bugreport.

1 vote
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 15, 2013

You are correct about 1 and 2, but 3 is a bit different. `getProject()` on that line is not being called on pageState, but on a Repository object. `Repository.prototype.getProject()` IS formed dynamically, but it exists immediately on any repository. The actual issue is that there is no repository when we reach that line in the code. so when we run this.repository.getProject() we are calling undefined.getProject() which fails.

However, I've not been able to produce this so I don't understand what's going on for you.

Here is what should happen:

  1. The page that lists all the hooks loads, and the pageState is populated with the current project and repository. So pageState.getRepository() will return the current repository.
  2. Then the user clicks the button to Enable your hook, and a dialog pops up with your form inside of it. At this point, the RevisionReferenceSelector is initialized, and evaluates pageState.getRepository(). For me, this returns a real object, but I'm assuming that for you it returns undefined.
  3. User clicks the BranchSelector widget and the repository it grabbed earlier is evaluated.

If that's not how you're using the branch selector field, then please give me more details on how you're using it. You might need to manually add a dependency on it, or manually call `pageState.setRepository(repoJson);` for your page (which is a bit dirty) or change it to use one of the repository decorators.

If that is how you're using the branch selector field, you may benefit from debugging into `initRepositoryPageState` in /layout/repository/repository.js . The repository should be added to pageState in that function. Perhaps a previous error is causing that not to run, or later code is overwriting it for some reason. This is hard for me to help with since I can't reproduce your problem locally.

Cheers,

Adam

TAGS
AUG Leaders

Atlassian Community Events