Hi All,
I am facing...Can you please suggest me something to acheiving this,
Problem : Suppose one branch in GIT saying that DEV1 and administrator committed some files and pushed the same to server.
I have also checkout the same branch and worked something on it and committed the message locally but I am not able to push my work directly on server because I dont have permission for that. So I have created local branch on DEV1 and pushed the same.
I wrote HOOK which take care of commit message which is in pre-defined format in regular expression. If committed message match then user can push there code otherwise hook will reject the push.
My problem is, when we create the local branch i want to read only those commit message which I added after administrator change but it is returning all the commit messages which is already committed by administator in DEV1.
We are using below code snippets in pre-HOOK,
----------------------------------------------------------------------------------------------------
public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)
{
for (RefChange refChange : refChanges)
{
ChangesetsBetweenRequest request = new ChangesetsBetweenRequest.Builder( context.getRepository()).exclude(refChange.getFromHash()) .include(refChange.getToHash()).build();
final Page<Changeset> cs = commitService.getChangesetsBetween( request, PAGE_REQUEST);
for (Changeset changeset : cs.getValues()) {
commit_msg = changeset.getMessage();
}
}
}
Please suggest me how can we read the latest commit messages.
I want to read the localcommits , I dont want to read the pushed commits. How can I achieve it.
Regards,
Anil
You can detect commits which do not already exist on the server like this (changesetIndex is this class):
for(Changeset changeset: cs.getValues()) { //false for new commits, true for old ones if (!changesetIndex.isMemberOf(changeset.getId(), repository)) { //do stuff } }
Hi Balazs thanks for the suggestion , its worked.
And in one scenario, i.e., If I create any branch and without commit anything If I push the empty branch then the branch should push to server or it shouldn't.
Regards
Anil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still I have this doubt..can we allow empty branch to push to server or not..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is wrong with empty branches?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm checking for commit message whether the commit message having valid ticket number or not. Able to do it with pre-hook.
Now, If I created a new branch then from Hash Id getting "00000000000000....000". It is trying to read all the changesets.
I restricted to do work with only local-commits other than pushed ones with isMember( ) method (This is of your suggested method in other threads).
Is there any check whether the brancch pushed with changes or empty changes so that. If the empty branch pushed il just allow it to push other than the other stufff which I'm doing.
Regards
Anil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.