git pull origin refs/changes/92/*and thengit pull origin master
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
I think that this functionality might be useful in one of the gerrit
helper scripts like repo or git-review:
https://github.com/openstack-ci/git-review
I know this is something that I would find valuable. And it would be
especially useful if reviewers are ever able to edit changes through
the web interface (to do things like fix minor typos).
Maybe you could replace git fetch to warn you if any of your commits
are outdated by fetching all the changesets and comparing where the
newest version of the change is.
Jason
> I have a workflow (attached screenshot) with my team where before any
> change is made to a local branch the Developer executes a "git pull".
> This pull gets any changes which have been merged into master since
> the last pull was made.
I was just about to bark about using "git pull --rebase" instead of a
plain "git pull", but according to the workflow diagram you're already
doing that. Good.
> As a QA lead, I sometimes fix some issues for the Developer. To do
> this, I fetch the latest patch of the changeset and modify the code
> locally and push the changes back to refs/for/master. This results in
> a new patch for the changeset with the committer being myself.
>
> The problem I am facing is when the Developer pulls the changes with
> "git pull" he will not get the latest patch I submitted, which is
> obvious because the git pull only gets the changes from master branch.
> How can I automate the pull so that it fetches the latest changes from
> master as well from the changeset branch?
>
> Is there a wildcard syntax I can use e.g.
>
> git pull origin refs/changes/92/*
> and then
> git pull origin master
Well, Git's fetch refspecs can contain wildcards so I guess you
could fetch refs/changes/x/* (where x is the change number mod 100)
and find the patch set you're looking for by examining FETCH_HEAD.
But I'd rather suggest you use the "query" SSH command for this
(see http://goo.gl/0KzVm). Use the --current-patch-set option and
select JSON output. It shouldn't take many lines of e.g. Python
to produce the refspec that needs to be pulled (I believe the
refspec of each patch set is in a field of its own).
Or, the developer will just have to look up the refspec to pull
from via the Gerrit web UI.
--
Magnus Bäck
ba...@google.com
refs/changes/92/292/1
refs/changes/92/292/2
refs/changes/92/292/3
refs/changes/92/292/4
refs/changes/92/292/5
refs/changes/92/292/6
refs/changes/92/292/7
refs/changes/92/292/8
refs/changes/92/292/9
refs/changes/92/292/10
refs/changes/92/292/11
refs/changes/92/292/12
refs/changes/92/292/13
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
--
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
> Using the gerrit query command, I am able to get the list of
> refs/patches on the remote:
>
> refs/changes/92/292/1
> refs/changes/92/292/2
> refs/changes/92/292/3
> refs/changes/92/292/4
> refs/changes/92/292/5
> refs/changes/92/292/6
> refs/changes/92/292/7
> refs/changes/92/292/8
> refs/changes/92/292/9
> refs/changes/92/292/10
> refs/changes/92/292/11
> refs/changes/92/292/12
> refs/changes/92/292/13
>
> How can I verify those refs are available in the HEAD of the local
> branch I am in?
I assume you mean that you want to check that *one* of these commits
is reachable from HEAD, not that *all* are reachable from HEAD since
that will never be the case. You can use "git log" or "git rev-list"
to test reachability:
if [ $(git rev-list HEAD..<patch> | wc -l) -eq 0 ] ; then
echo "Patch reachable from HEAD"
fi
Don't forget that this will only work as long as you don't rebase
your topic branch.
--
Magnus Bäck
ba...@google.com
> here is my attempt of syncing all refs of the changeset:
>
> #!/bin/sh
>
> # Extract the Change Id from HEAD
> CHANGE_ID=$(git show HEAD --summary | grep "Change-Id:" | awk -F ' '
> '{print $2}')
If HEAD is a commit that has been uploaded (I don't really understand
what you're trying to do so I can't judge whether this will be the case)
you can use the fact that the query command accepts a SHA-1 as input:
SHA1=$(git rev-parse HEAD)
Then, pass $SHA1 as the query.
> if [ "${CHANGE_ID}" != "" ]; then
>
> # Get the Gerrit changeset number
> CHANGESET_NUMBER=$(ssh source-code gerrit query "${CHANGE_ID}" |
> grep "number:" | awk -F ' ' '{print $2}')
The grep expression is fragile; you should make sure you only match
"number:" at the beginning of lines:
... | grep "^ *number: " | ...
> # Get the Changeset Refs
> CHANGESET_REFS=$(ssh source-code gerrit query --patch-sets
> "${CHANGESET_NUMBER}" | grep "ref:" | awk -F ' ' '{print $2}')
>
> # Fetch all the refs from Remote
> for ref in "${CHANGESET_REFS}"; do git fetch origin $ref && git
> reset --hard FETCH_HEAD; done;
> fi
While it won't make much of a difference in most cases, there's no need
to waste time on running "git reset" in each iteration of the loop.
--
Magnus Bäck
ba...@google.com
err, pipe2 = os.popen2("git log --oneline --format='%H'
origin/dev..HEAD | awk '{print $1}'")
commits = [line.strip() for line in pipe2]
print commits
for x in commits:
print "x is %s" % x
inGerrit = gerrit("query %s|grep rowCount:|awk '{print $2}'" % x)
inGerrit = inGerrit.strip()
print "in gerrit is %s" % inGerrit
if inGerrit == "0":
print "is not in gerrit"
elif inGerrit == "1":
print "is in gerrit"
else:
print "ERROR in Gerrit is %s" % inGerrit
Jason
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
On Sunday, February 26, 2012 at 05:16 EST,
Jeffery Fernandez <jefferyf...@gmail.com> wrote:> here is my attempt of syncing all refs of the changeset:
>
> #!/bin/sh
>
> # Extract the Change Id from HEAD
> CHANGE_ID=$(git show HEAD --summary | grep "Change-Id:" | awk -F ' '
> '{print $2}')If HEAD is a commit that has been uploaded (I don't really understand
what you're trying to do so I can't judge whether this will be the case)
you can use the fact that the query command accepts a SHA-1 as input:
SHA1=$(git rev-parse HEAD)
Then, pass $SHA1 as the query.
> if [ "${CHANGE_ID}" != "" ]; then
>
> # Get the Gerrit changeset number
> CHANGESET_NUMBER=$(ssh source-code gerrit query "${CHANGE_ID}" |
> grep "number:" | awk -F ' ' '{print $2}')The grep expression is fragile; you should make sure you only match
"number:" at the beginning of lines:
... | grep "^ *number: " | ...
> # Get the Changeset Refs
> CHANGESET_REFS=$(ssh source-code gerrit query --patch-sets
> "${CHANGESET_NUMBER}" | grep "ref:" | awk -F ' ' '{print $2}')
>
> # Fetch all the refs from Remote
> for ref in "${CHANGESET_REFS}"; do git fetch origin $ref && git
> reset --hard FETCH_HEAD; done;
> fiWhile it won't make much of a difference in most cases, there's no need
to waste time on running "git reset" in each iteration of the loop.
--
Magnus Bäck
ba...@google.com
--
Magnus Bäck
ba...@google.com