mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	review: Automatically push personal local branches to the remote.
(imported from commit 29cf7d7316eb3666e2f8b39aacf3baa86990bace)
This commit is contained in:
		
							
								
								
									
										23
									
								
								tools/review
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								tools/review
									
									
									
									
									
								
							@@ -153,8 +153,27 @@ def make_header(repo, opts, revs):
 | 
			
		||||
      name = name[len(prefix):]
 | 
			
		||||
      tip_name = '%s (%s)' % (name, revs[-1].hexsha[:7])
 | 
			
		||||
  else:
 | 
			
		||||
      print >>sys.stderr, "WARNING: Can't find this commit in remote -- did you push?"
 | 
			
		||||
      tip_name = revs[-1].hexsha[:7]
 | 
			
		||||
    (_, local_name) = repo.git.name_rev(revs[-1].hexsha,
 | 
			
		||||
                                        refs='refs/heads/*',
 | 
			
		||||
                                        always=True).split()
 | 
			
		||||
    if local_name == "undefined":
 | 
			
		||||
      print >>sys.stderr, "ERROR: Can't find this commit in remote or identify local branch!"
 | 
			
		||||
      sys.exit(1)
 | 
			
		||||
 | 
			
		||||
    email_basename = get_current_user_email(repo).split("@")[0]
 | 
			
		||||
    if local_name.startswith("%s-" % (email_basename,)):
 | 
			
		||||
      # Try to push the local branch to the remote automatically
 | 
			
		||||
      try:
 | 
			
		||||
        print "Attempting to push %s to remote %s" % (local_name, remote)
 | 
			
		||||
        repo.git.push(remote, local_name)
 | 
			
		||||
        tip_name = '%s (%s)' % (local_name, revs[-1].hexsha[:7])
 | 
			
		||||
      except git.GitCommandError, e:
 | 
			
		||||
        print >>sys.stderr, "ERROR: Couldn't push %s to remote" % (local_name,)
 | 
			
		||||
        print >>sys.stderr, e
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    else:
 | 
			
		||||
      print >>sys.stderr, "ERROR: Can't find this commit in remote -- did you push %s?" % (local_name)
 | 
			
		||||
      sys.exit(1)
 | 
			
		||||
 | 
			
		||||
  objective_summary = '%d commit(s) to %s' % (len(revs), tip_name)
 | 
			
		||||
  summary = ('%s (%s)' % (opts.summary, objective_summary) if opts.summary
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user