Project

General

Profile

Feature #7080 ยป 0001-7080-git-pbchk-could-evolve-automatic-parent-branch-.patch

update patchset to use PBCHK_BRANCH + updated manpage - Richard PALO, 2016-06-09 05:57 AM

View differences:

usr/src/tools/scripts/git-pbchk.1onbld
12 12
.\"
13 13
.\" Copyright 2011 Richard Lowe.
14 14
.\" Copyright 2015 Elysium Digital, L.L.C.
15
.\" Copyright 2016 PALO, Richard.
15 16
.\"
16 17

  
17 18
.TH "GIT\-PBCHK" "1ONBLD" "April 23, 2015" "" ""
......
66 67
\fB\-b branch\fR:
67 68

  
68 69
.IP
69
Compare the current workspace to /branch/ for the purposes of generating file and comment lists\.
70
Compare the current workspace to \'branch\' for the purposes of generating file and comment lists\.
70 71

  
71 72
.IP
72
If this option is not specified an attempt is made to determine this automatically, if the git branch configuration contains this information\.
73
If this option is not specified an attempt is made to determine this automatically for \'tracking\' branches\.
73 74

  
74 75
.IP
75
If no branch is specified and none can be determined automatically \fBorigin/master\fR is used\.
76
If no branch is specified and none can be determined automatically then the value
77
of the environment variable \'PBCHK_BRANCH\' is used, if defined, or \fBorigin/master\fR if not\.
76 78

  
77 79
.SH "FILES"
78 80
\fBgit nits\fR and \fBgit pbchk\fR support NOT files of the form used by Cadmium with Mercurial\. These are looked for in \fB$CODEMGR_WS/\.git/\fR and in \fB$CODEMGR_WS/exception_lists/\fR as normal\. The files are named after the check from which they exclude files\.
usr/src/tools/scripts/git-pbchk.py
20 20
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
21 21
# Copyright (c) 2014, Joyent, Inc.
22 22
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
23
# Copyright 2016 PALO, Richard.
23 24
#
24 25

  
25 26
import getopt
......
99 100
def git_branch():
100 101
    """Return the current git branch"""
101 102

  
102
    p = git('branch')
103
    p = git('branch --contains HEAD')
103 104

  
104 105
    if not p:
105 106
        sys.stderr.write("Failed finding git branch\n")
......
115 116
def git_parent_branch(branch):
116 117
    """Return the parent of the current git branch.
117 118

  
118
    If this branch tracks a remote branch, return the remote branch which is
119
    tracked.  If not, default to origin/master."""
119
    If this is a 'tracking' branch, return the remote branch which is tracked.
120

  
121
    Otherwise default to the environment variable PBCHK_BRANCH, if defined,
122
    or to 'origin/master' if not."""
120 123

  
121 124
    if not branch:
122 125
        return None
123 126

  
124
    p = git("for-each-ref --format=%(refname:short) %(upstream:short) " +
125
            "refs/heads/")
127
    p = git("for-each-ref --format=%(upstream:short) " +
128
            "refs/heads/{0!s}".format(branch))
126 129

  
127 130
    if not p:
128 131
        sys.stderr.write("Failed finding git parent branch\n")
129 132
        sys.exit(err)
130

  
131
    for line in p:
132
        # Git 1.7 will leave a ' ' trailing any non-tracking branch
133
        if ' ' in line and not line.endswith(' \n'):
134
            local, remote = line.split()
135
            if local == branch:
136
                return remote
137
    return 'origin/master'
133
    else:
134
       parent = p.readline().rstrip()
135
       p.close()
136
       if len(parent) > 0:
137
           print("Choosing '{0}' as tracked parent.\n".format(parent))
138
           return parent
139

  
140
    d_parent = os.getenv("PBCHK_BRANCH","origin/master")
141
    print("Choosing '{0}' as default parent.\n".format(d_parent))
142
    return d_parent
138 143

  
139 144

  
140 145
def git_comments(parent):
141
- 
    (1-1/1)