[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser-build][main] Bug 40796: Improve the UX for the changelogs script when using the issue number



Title: GitLab

Richard Pospesel pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

  • ad6a7516
    by Pier Angelo Vendrame at 2023-02-22T18:57:43+01:00
    Bug 40796: Improve the UX for the changelogs script when using the issue number
    

1 changed file:

Changes:

  • tools/fetch-changelogs.py
    ... ... @@ -102,30 +102,44 @@ with token_file.open() as f:
    102 102
         token = f.read().strip()
    
    103 103
     headers = {"PRIVATE-TOKEN": token}
    
    104 104
     
    
    105
    -if sys.argv[1][0] != "#":
    
    106
    -    version = sys.argv[1]
    
    107
    -    r = requests.get(
    
    108
    -        f"{API_URL}/projects/{PROJECT_ID}/issues?labels=Release Prep",
    
    109
    -        headers=headers,
    
    110
    -    )
    
    111
    -    issue = None
    
    112
    -    for i in r.json():
    
    113
    -        if i["title"].find(sys.argv[1]) != -1:
    
    114
    -            if issue is None:
    
    115
    -                issue = i
    
    116
    -            else:
    
    117
    -                print("More than one matching issue found!")
    
    118
    -                print("Please use the issue id.")
    
    119
    -                sys.exit(3)
    
    120
    -    if not issue:
    
    121
    -        print(
    
    122
    -            "Release preparation issue not found. Please make sure it has ~Release Prep."
    
    105
    +version = sys.argv[1]
    
    106
    +r = requests.get(
    
    107
    +    f"{API_URL}/projects/{PROJECT_ID}/issues?labels=Release Prep",
    
    108
    +    headers=headers,
    
    109
    +)
    
    110
    +if r.status_code == 401:
    
    111
    +    print("Unauthorized! Has your token expired?")
    
    112
    +    sys.exit(3)
    
    113
    +issue = None
    
    114
    +for i in r.json():
    
    115
    +    if i["title"].find(sys.argv[1]) != -1:
    
    116
    +        if issue is None:
    
    117
    +            issue = i
    
    118
    +        else:
    
    119
    +            print("More than one matching issue found!")
    
    120
    +            print("Please use the issue id.")
    
    121
    +            sys.exit(4)
    
    122
    +if not issue:
    
    123
    +    iid = version
    
    124
    +    version = None
    
    125
    +    if iid[0] == "#":
    
    126
    +        iid = iid[1:]
    
    127
    +    try:
    
    128
    +        int(iid)
    
    129
    +        r = requests.get(
    
    130
    +            f"{API_URL}/projects/{PROJECT_ID}/issues?iids={iid}",
    
    131
    +            headers=headers,
    
    123 132
             )
    
    124
    -        sys.exit(4)
    
    125
    -    iid = issue["iid"]
    
    126
    -else:
    
    127
    -    version = "????"
    
    128
    -    iid = sys.argv[1][1:]
    
    133
    +        if r.ok and r.json():
    
    134
    +            issue = r.json()[0]
    
    135
    +    except ValueError:
    
    136
    +        pass
    
    137
    +if not issue:
    
    138
    +    print(
    
    139
    +        "Release preparation issue not found. Please make sure it has ~Release Prep."
    
    140
    +    )
    
    141
    +    sys.exit(5)
    
    142
    +iid = issue["iid"]
    
    129 143
     
    
    130 144
     linked = {}
    
    131 145
     linked_build = {}
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits